Mar 1, 2010 #1 flower45 Programmer Joined Mar 1, 2010 Messages 1 Location 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
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
Mar 1, 2010 #2 Annihilannic MIS Joined Jun 22, 2000 Messages 6,317 Location AU 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. Upvote 0 Downvote
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.
Mar 16, 2010 #3 Ogzilal MIS Joined Oct 9, 2003 Messages 280 Location FR 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 Upvote 0 Downvote
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