Guys,

I'm quite new with awk and wanna do something like this:
let say i have a file with this content :
aaaa,bbbb,cccc,dddd

and i wanna do an insert of " " only on the third column. and the output to be like this :

aaaa,bbbb,"cccc",dddd

fyi, the file contains millions rows and i need to consistently insert " " on the third column.

Please help. Your solution really will save my time a lot!

Cheers,
Faizals

Not very familiar with awk myself, but you could try the following:
awk -F"," '{print $1","$2",\""$3"\","$4}' test.txt

This assumes you use the comma (,) as seperator and that there are 4 columns.

Not very familiar with awk myself, but you could try the following:
awk -F"," '{print $1","$2",\""$3"\","$4}' test.txt

This assumes you use the comma (,) as seperator and that there are 4 columns.

awesome mike! that save my day! cheers!


$ cat t | awk -F"," '{ print $1","$2",\""$3"\","$4}'
aaaa,bbbb,"cccc",dddd

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.