I am having a file which contains negative numbers, wht i am doing is re-formattting the file(moving few columns and add few hard codings between), while reformatting i would want the negative numbers to have the sign as trailing rather than leading.
Existing
-2400.00
34
0.00
-987.00
-92.56
Required
2400.00-
34
0.00
987.00-
92.56-
FYI am using awk on every line to reformat the line to create a new format
cat $FILENAME |grep ^3 | while read line
do
echo "$line" | nawk ' BEGIN {FS=","} {print("5",$1,$28,"$27",$26)}' >> New_file
done
Thank you ITKAMARAJ..
I am actually going to use printf to use certain formatting(like padding with zero etc)
nawk '{ if(index($0,"-") > 0){print substr($0,2,length($0))"-"} else {print $0}}' test
the above worked perfectly fine ... in that case i will have to first use this to the file(to conver the column with trailing sign and then use my other formatting ? or can i include the above to this statement
nawk ' /^3/ BEGIN {FS=","} {print("5",$1,$28,"$27",$26)}' $FILENAME