Hi All,
I have a input file named 'inputtest.txt' like below:
"335588","DW02.CAPTURED_ROC_14","13016063","00000000000001541897035.77"
"335587","DW02.NCL01_1ST_PSMT_14","446301","00000000000000040370306.43"
My desired output will be like below:
335588 DW02.CAPTURED_ROC_14 13016063 001541897035.77
335587 DW02.NCL01_1ST_PSMT_14 446301 000040370306.43
I executed the below command:
sed 's/["]//g;s/[,]/ /g' inputtest.txt | awk '{ printf "%-7s\t%-18s\t%-10s\t%-12.2f\n", $1, $2, $3, $4}'
and got the output like:
335588 DW02.CAPTURED_ROC_14 13016063 1541897035.77
335587 DW02.NCL01_1ST_PSMT_14 446301 40370306.43
Note: The fourth column of my output file truncates leading zero's. Please help me out on this.
Try:
awk -F, '{
gsub("\"","")
printf "%-7s\t%-18s\t%-10s\t%015.2f\n", $1, $2, $3, $4
}' file
Hi,
As per my understanding, when we use %012.2f in printf will keeps leading zero values. But it is not coming like this. Please explain.
And when i use the above code as it is, i am getting error:
Please correct me if i'm wrong anywhere.
If you want the command on one line you have to separate the statements with a semicolon:
awk -F, '{ gsub("\"",""); printf "%-7s\t%-18s\t%-10s\t%015.2f\n", $1, $2, $3, $4 }' inputfile.txt
^