Print required values at end of the file by using AWK

I am looking help in awk, quick overview. we will get feed from external system . The input file looks like below.

Detail Id Info Id Order Id STATUS Status Date FileDetail 
99127942 819718 CMOG223481502 PR 04-17-2011 06:01:34PM 60_R010|BDLPRICE|634691922|DATA|Y|Y|634691938|20110417|C|634691927-1|32011|G8618|H7174-1|||||||||||||||||||||||||||||| 

FileDetails column value is in pipe delimited.

My request is to create new file with all above column values and extra columns values at the end . Here my extra column names are (AID,SID, DATE) . The values of this new three columns should populate from FileDetail value. I am looking my output file like below

Detail Id Info Id Order Id STATUS Status Date FileDetail AID SID DATE 
99127942 819718 CMOG223481502 PR 04-17-2011 06:01:34PM 60_R010|BDLPRICE|634691922|DATA|Y|Y|634691938|20110417|C|634691927-1|32011|G8618|H7174-1|||||||||||||||||||||||||||||| 634691922 634691938 20110417 

Last three values(634691922 634691938 20110417) I have copied by FileDetail values that are pipe delimited which are in bold.

I tried with bleow command but did not get required output.

awk -F'[ |]+' '{ print ($1 "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t" $9 "\t" $13 "\t" $14)} ' input.txt

any other solution is appreciate.

Thanks,

Will this work for you:

sed 's/$/634691922 634691938 20110417/' Inp_File

thanks for update. when i ran same command I am getting same values for other records like bleow.

sed 's/$/634691922 634691938 20110417/' input.txt
Detail Id    Info Id    Order Id         STATUS    Status Date               File Detail                                                                                                                          634691922 634691938 20110417
98850008     816148     CMOG221598756    PR        04-02-2011 06:00:24PM     60_R010|BDLPRICE|596695619|DATA|Y|N|596695629|20110402|C|846101152-1|26108|Y5893|H7239-1||||||||||||||||||||||||||||||               634691922 634691938 20110417
98850009     816148     CMOG221598771    PR        04-02-2011 06:00:26PM     60_R010|BDLPRICE|480566958|DATA|Y|Y|480566977|20110402|C|480566963-1|32010|G8607|H7187-1||||||||||||||||||||||||||||||               634691922 634691938 20110417 (these values should replace with above bold Green color values)
98850010     816148     CMOG221598780    PR        04-02-2011 06:00:28PM     60_R010|BDLPRICE|610843968|DATA|Y|N|610843981|20110402|C|610843972-1|25930|Y4820|H7438-1||||||||||||||||||||||||||||||               634691922 634691938 20110417 (these values should replace with above bold RED color values)

This will work same value for all records. but I want to check reach record in input file and print the values at end. above two records in green and red color are output examaples.

Thanks

---------- Post updated at 05:15 PM ---------- Previous update was at 05:01 PM ----------

I am looking the output file as below.

Detail Id    Info Id    Order Id         STATUS    Status Date               File Detail                                                                                                                          
98850008     816148     CMOG221598756    PR        04-02-2011 06:00:24PM     60_R010|BDLPRICE|596695619|DATA|Y|N|596695629|20110402|C|846101152-1|26108|Y5893|H7239-1||||||||||||||||||||||||||||||               596695619 596695629 20110402
98850009     816148     CMOG221598771    PR        04-02-2011 06:00:26PM     60_R010|BDLPRICE|480566958|DATA|Y|Y|480566977|20110402|C|480566963-1|32010|G8607|H7187-1||||||||||||||||||||||||||||||               480566958 480566977 20110402
98850010     816148     CMOG221598780    PR        04-02-2011 06:00:28PM     60_R010|BDLPRICE|610843968|DATA|Y|N|610843981|20110402|C|610843972-1|25930|Y4820|H7438-1||||||||||||||||||||||||||||||               610843968 610843981|20110402

Last three values I have picked from filedetail values which is delmited by pipe.(Third,7th and 8th value)

thanks

Out of curiosity, would this have worked as well?

awk -F'[ |]' '/^[0-9]/ {$49=$9; $50=$13; $51=$14} {print $0, $49, $50, $51}' input.txt

with the above command i am getting blank values separeated by coma.

awk -F'[ |]' '/^[0-9]/ {$49=$9; $50=$13; $51=$14} {print $0, $49, $50, $51}' input.txt >> two.txt

obbhvpd1> vi two.txt
"two.txt" 196 lines, 42138 characters

Detail Id    Info Id    Order Id         STATUS    Status Date               File Detail                                                                                                                          ,,,,,
98850008     816148     CMOG221598756    PR        04-02-2011 06:00:24PM     60_R010|BDLPRICE|596695619|DATA|Y|N|596695629|20110402|C|846101152-1|26108|Y5893|H7239-1||||||||||||||||||||||||||||||               ,,,,,
98850009     816148     CMOG221598771    PR        04-02-2011 06:00:26PM     60_R010|BDLPRICE|480566958|DATA|Y|Y|480566977|20110402|C|480566963-1|32010|G8607|H7187-1||||||||||||||||||||||||||||||               ,,,,,
98850010     816148     CMOG221598780    PR        04-02-2011 06:00:28PM     60_R010|BDLPRICE|610843968|DATA|Y|N|610843981|20110402|C|610843972-1|25930|Y4820|H7438-1||||||||||||||||||||||||||||||               ,,,,,
98850011     816148     CMOG221598790    PR        04-02-2011 06:00:30PM     60_R010|BDLPRICE|615320070|DATA|Y|Y|615320086|20110402|C|615320074-1|25930|Y4820|H7262-1||||||||||||||||||||||||||||||               ,,,,,
98850012     816148     CMOG221598800    PR        04-02-2011 06:00:32PM     60_R010|BDLPRICE|616033096|DATA|Y|Y|616033107|20110402|C|616033098-1|32010|G8607|H7176-1||||||||||||||||||||||||||||||               ,,,,,

Thanks.

See if this works for you:

sed 's/.*|\([0-9]\{9\}\)|.*|\([0-9]\{9\}\)|\([0-9]\{8\}\)|.*/& \1 \2 \3/' Inp_File

This command works perfect for me. thank you very much. But I am looking all column values to create with tab delimited or comma(m)delimited in new file. When I try with below command its the values are not creating with tab delimited.

sed 's/.*|\([0-9]\{9\}\)|.*|\([0-9]\{9\}\)|\([0-9]\{8\}\)|.*/& \1 \2 \3/' '\t' input.fil > one.txt

Also I have two other input files that need to create with same . As I am new to SED I can't able to create sed by refering your command. Can you please check and provide sed command for below files too with tab delimited out put file.

Detail Id    Info Id    Order Id         STATUS    Status Date               File Detail
99191222     820308     CMOG224013751    PR        04-20-2011 07:00:27PM     20_R28|BQTBIZ_PRICEUP|776598279|776598280|20110420|C|Y7371-1|26342|Y7364|H7018-1|Y|N| 776598279 776598280 20110420
99191223     820308     CMOG224013767    PR        04-20-2011 07:00:31PM     20_R28|BQTBIZ_PRICEUP|772963162|772963163|20110420|C|Y7291-1|25525|Y2548|H7082-1|Y|N| 772963162 772963163 20110420
Detail Id    Info Id    Status    Status Date               File Detail            Error Code Error Desc
99191240     820308     ER        04-20-2011 07:01:25PM     20_R28|BQTBIZ_PRICEUP|16716056|16716059|20110420|C|G5935-1|6500|G6725|H7027-1|Y|N|           226113     Action is not allowed on a service with pending orders 16716056 16716059 20110420
99191489     820308     ER        04-20-2011 07:02:23PM     20_R28|BQTBIZ_PRICEUP|780442679|780442680|20110420|C|Y2516-1|25790|Y4490|H7094-1|Y|N|  780442679 780442680 20110420  

your help is greatly thank full.

---------- Post updated at 03:40 PM ---------- Previous update was at 11:58 AM ----------

any help for my request..

You agreed to not bump posts when you registered, please don't.

To change from spaces to tabs, change the spaces in the expression into tabs, or \t