replacing one filed at run time in UNix

Hi All,
My requirement is :
My input file is :

2 , 56, 23, 43,
1 , 32 , 5, 6,
10 , 2, 3, 4,

Now i want the output as
new, 56, 23, 43,
new,32 , 5, 6,
new , 2, 3, 4,

Please help me

Rawat

what have you tried so far ? :confused: :confused: :confused:

try this,

Hi
Thanks for the prompt reply.
Actuaaly i have a file with around 115 fileds in each row.
So with your method it will work but will be clumsy to write such a big code
.
Any simpler code !!

Thanks a lot
Rawat

sed -e "s/^[^,]*\(,.*\)/new \1/g" input.txt > output.txt

Hi Vino,

Can you pls explain your command as I'm trying to learn sed too and it'll be helpful for me.

thanks
Patras

sed -e "s/^[^,]*\(,.*\)/new \1/g" input.txt > output.txt

[^,]* means a character-set containing all those characters which are not , (comma)
\(,.*\) is capture a string which matches the pattern , (comma) followed by anything.

Then replace the character-set with *new* followed by the pattern.

Write everything into output.txt

with awk for any no. of fields

Gaurav

Hi
Thanks for the reply :
The command :
sed -e "s/^[^,]*\(,.*\)/new \1/g" input.txt > output.txt
Works perfectly fine.

rawat