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

Adding quotes

Status
Not open for further replies.

dtanner

Technical User
Dec 19, 2001
10
US
I have a list of equipment numbers like
MO531
MO532
....etc etc

Would like to convert them to read
'MO521','MO532', and so on.

Thanx in advance.
DT In order to prevent possible injury to yourself, or your computer, and to ensure readability, please do not smoke, eat, drink, spindle, bend, fold, staple, or mutilate this message.
 
Hi dtanner,

You could use
Code:
{
  printf "\047" $0 "\047" ","
}
Hope this helps. CaKiwi
 
Well that solved getting them all on one line but not the single quote. I get \047 instead of the '.

thanx
DT In order to prevent possible injury to yourself, or your computer, and to ensure readability, please do not smoke, eat, drink, spindle, bend, fold, staple, or mutilate this message.
 
Mmmmm, what version of awk are you using? I you are on solaris you need to use nawk. If you are on an old version of some some flavour of unix you may need to get gawk. CaKiwi
 
Hi,

Try this :

{
if (NR > 1) printf "," ;
printf "'" $0 "'" ;
}
Jean Pierre.
 
Right idea, but syntax wrong.

{
if (NR > 1) printf ","
printf ("'%s'", $0)
}END{printf "\n"}

This works now.

HTH


flogrr
flogr@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top