My input file is as follows:
12/13/2011,07:14:13.724,12/13/2011 07:14:13.724,231.56.3.245,LasVegas,US
I wish to get the following:
<
Since the sed
solution has already been posted, here is an alternate awk
solution:
[jaypal:~/Temp] cat inputfile
12/13/2011,07:14:13.724,12/13/2011 07:14:13.724,231.56.3.245,LasVegas,US
[jaypal:~/Temp] awk -F"," -v ORS="," '
{for(i=1;i
Explanation:
,
and Output Record Separator to ,
. for loop
we will loop over each fields.if loop
we would do substitution
to the fields when the for loop
parses over second and third fields. for loop
for we just print out $NF
which is the last field. This won't cause a ,
to be printed after last field.