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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

printing quotes using printf

Status
Not open for further replies.

IMAUser

Technical User
May 28, 2003
121
CH
How can a print quotes using printf.

printf ( "%s , %s, %s ", &aa , &bb, &cc );

I need the o/p to read

'Firstcol','Secondcol','Third Column'

Thanks


 
Use the octal value...

printf "\047%s\047,\047%s\047,\047%s\047", $1, $2, $3
 
No I have tried that and it dosent work.
Actually there is a mistake in the question itself. Since this is a AWK printf
printf(" ' %s' , %s ,%s \n", $3, $2, $1)

So that dosent work.
I have tried the regular slashes and extra quotes, but not found the anseer yet.
 
Tested...

echo one two three|awk '{printf "\047%s\047,\047%s\047,\047%s\047", $1, $2, $3}'

Result...

'one','two','three'
 
Thanks the Octal value solution works.
Actually my First reply was to Salem , and just inserting quotes did not work.

Thanks, Ygor.
 
> Actually my First reply was to Salem , and just inserting quotes did not work.
Since you are using an AWK command line rather than an AWK program (where my answer works), your question was really "how do I protect ' from being interpreted by the shell" rather than "how do I print a ' using AWK"

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top