I have file which contain line below like I want to manage through awk
filename:-test.txt
"A","@900",9999,"Test Place","Quayside Sc, Sligo, Tel: 071 9154382","SCRIPT",20150317
I want to manage this is as single string "Quayside Sc,Sligo, Tel: 071 9154382"
It automatically take first string before comma when I perform following command
echo "A","@900",9999,"Test Place","Quayside Sc, Sligo, Tel: 071 9154382","SCRIPT",20150317 | awk -F ',' '{ print $4 "|" $8 }'
Test Place|SCRIPT
Using
FPAT
in gnu-awk you can get whole quoted string as single field:FPAT="\"[^\"]*\"|[^,]*"
uses a regex to break down fields surrounded by quotes or separated by comma.For demo purpose here is each parsed field:
Update: If you don't have gnu-awk 4 then you can use this
perl
command for same effect: