prefix 2nd column in csv file in unix box

February 1, 2011 at 01:33:23
Specs: Windows XP
Hi,

Need help in prefixing a value to 2nd column in csv file.

Current file looks like
11001,4343,rrr,250
11201,6643,rrvb25
11051,8443,rer,150

The output should be

11001,74343,rrr,250
11201,76643,rrvb25
11051,78443,rer,150

number 7 is appended to 2nd column.


See More: prefix 2nd column in csv file in unix box

Report •


#1
February 1, 2011 at 07:04:16
Use awk to change the 2nd field using a Field Seperator of comma:

#!/bin/ksh

awk ' BEGIN { FS=OFS="," }
{
$2="7"$2
print $0
} ' data.txt


Report •

#2
February 1, 2011 at 21:53:46
Thanks nails.

you nailed it :)


Report •

Related Solutions


Ask Question