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!

AWK Print Format

Status
Not open for further replies.

PADFOR

Programmer
Feb 5, 2001
25
GB
I need to print a variable with single quotes around it. I have tried the following awk command:

awk -F: '{print &quot;\'&quot; $1 &quot;\'&quot;}' <filename>

It produces the error:

Unmatched &quot;

I would like to print the variable in the format:

'<variable>'

Any suggestions would be grateful.
 
On my awk version on HP-UX 10.20 you can use either &quot;'&quot; or &quot;\047&quot; for line within a script. And on the command line you have to use &quot;\047&quot;. I'd always go with &quot;\047&quot;. So try:

# inside script
awk -F: '{print &quot;'&quot; $1 &quot;'&quot;}' <filename>

# on command line
awk -F: '{print &quot;\047'&quot; $1 &quot;\047&quot;}' <filename>
Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top