Hi,
I have around 10 files in a folder in which I want to change the file format from tab(\t) to pipe(|) with some changes in the fields as well. Below is the code, while tmp file is getting generated but move command is not working, please help
Following is the code
awk -F"\t" '{print $1,$2,substr($3,1,2)substr($3,4,2)substr($3,7,2),substr($4,7,4)substr($4,1,2)substr($4,4,2),$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31 >> FILENAME".tmp" }END{system("mv " FILENAME".tmp" " " FILENAME)} ' OFS="|" *.PRC
Sample Input file
65535 1558 14:46:55 11/19/2014 8926877659 30239933826126 8926877659 45 0 0 0 0 20272 00000 2 802DBD5B 405891369800923 postpaid null null 20272 20272 OUT 14:47:40 561 561 144 null 405899153999998 405899153999998 63581439
65535 65535 14:46:21 11/19/2014 9143110710 8926328080 9143110710 88 0 0 0 0 23702 15930 2 8076C355 405891373813936 postpaid null 919153881217 23702 23702 OUT 14:47:49 295 295 159 null 405899153999998 405899153999998 58123387
65535 302 14:46:30 11/19/2014 8642035475 999 8642035475 84 HTLN 0 0 0 21170 00000 2 80CD9C6C 405891961388656 postpaid null null 21170 21170 OUT 14:47:54 562 562 144 null 405899153999998 405899153999998 47000903
65535 311 14:47:50 11/19/2014 9143110721 31809143110663 9143110721 28 0 0 0 0 23702 00000 2 8063898E 405891373813947 postpaid null null 23702 23702 OUT 14:48:18 295 295 144 null 405899153999998 405899153999998 63842634
65535 302 14:48:05 11/19/2014 9143110266 30618906570722 9143110266 21 0 0 0 0 22912 00000 1 80D295D1 405891350843985 postpaid null null 22912 22912 OUT 14:48:26 561 561 144 null 405899153999998 405899153999998 45469437