Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Split quote-comma delimeted file in unix

Status
Not open for further replies.

flower45

Programmer
Mar 1, 2010
1
0
0
US
Hi,

I have a file like

"aa","bb",'123"
"aa,a","cc","234"

I want cut column 3 which is 123 and 234. any help regading is greately appreciated. How i can use awk commant to perform above operation

Thanks in advance
 
Try this:

Code:
awk -F '[green]^"|","|"$[/green]' '{[b]print[/b] [blue]$4[/blue]}' inputfile > outputfile

Note that this assumes that every field is surrounded by quotes; if that's not the case it gets a little more complicated.

Annihilannic.
 
If your column is the last in the file and if you have "rev command" installed
reverse twice

Code:
rev /path/to/file | awk -F"," '{print $1}' |rev
and then remove " and ' using sed tr or your favorite tool
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top