May 14, 2002 #1 Kenton Technical User May 7, 2002 30 AU Hi again how do I print string quotes (" using awk? I have this: awk '{print $1, $2, $3} < infile 1,2,3 2,3,5 but I need 1,2,"3" 2,3,"5" (I wish I had a UNIX manual!!) Thanks Kenton
Hi again how do I print string quotes (" using awk? I have this: awk '{print $1, $2, $3} < infile 1,2,3 2,3,5 but I need 1,2,"3" 2,3,"5" (I wish I had a UNIX manual!!) Thanks Kenton
May 14, 2002 #2 toolkit Programmer Aug 5, 2001 771 GB Try: Code: printf "%s,%s,\"%s\"\n", $1,$2,$3 Cheers Neil Upvote 0 Downvote
May 14, 2002 Thread starter #3 Kenton Technical User May 7, 2002 30 AU Ummm, what am I doing wrong? awk '{printf "%s,%s,\"%s\"\n", $1,$2,$3}' < infile now gives 1,2,3,,"" 2,3,5,,"" Kenton B-( Upvote 0 Downvote
Ummm, what am I doing wrong? awk '{printf "%s,%s,\"%s\"\n", $1,$2,$3}' < infile now gives 1,2,3,,"" 2,3,5,,"" Kenton B-(
May 15, 2002 #4 toolkit Programmer Aug 5, 2001 771 GB You must specify the input field separator to be a comma, using the -F option to awk. awk splits on space by default. So your example should be: Code: awk -F',' '{printf "%s,%s,\"%s\"\n", $1,$2,$3}' < infile Cheers, Neil Upvote 0 Downvote
You must specify the input field separator to be a comma, using the -F option to awk. awk splits on space by default. So your example should be: Code: awk -F',' '{printf "%s,%s,\"%s\"\n", $1,$2,$3}' < infile Cheers, Neil