How to print out single quoted columns? 
Author Message
 How to print out single quoted columns?

Greetings!

 There is a file that contains the following.

 teamname

 team1
 team2
 team3
 ....

 I want to have them single quoted likt this:

 'team1'
 'team2'
 'team3'
 ...

So I typed...

 awk '{print "'\''", $1, "'\''"}' filename;

 However, what I got aftre this command is as follows:

 ' team1 '
 ' team2 '
 ' team3 '
 ....
That is, there are blanks between the quotes and each word.
How can I get them without the blanks.
 'team1'
 'team2'
 'team3'
 ....

thanks in advance.



Tue, 28 Jun 2005 09:45:04 GMT  
 How to print out single quoted columns?

Quote:

> Greetings!

>  There is a file that contains the following.

>  teamname

>  team1
>  team2
>  team3
>  ....

>  I want to have them single quoted likt this:

>  'team1'
>  'team2'
>  'team3'
>  ...

> So I typed...

>  awk '{print "'\''", $1, "'\''"}' filename;

>  However, what I got aftre this command is as follows:

>  ' team1 '
>  ' team2 '
>  ' team3 '
>  ....
> That is, there are blanks between the quotes and each word.
> How can I get them without the blanks.
>  'team1'
>  'team2'
>  'team3'

Remove the commas:

     awk '{print "'\''" $1 "'\''"}' filename

And with sed,

     sed "s/.*/'&'/" filename
--
Regards,

---Robert



Tue, 28 Jun 2005 11:22:25 GMT  
 How to print out single quoted columns?

Quote:

> Greetings!
>  There is a file that contains the following.
>  teamname
>  team1
>  team2
>  team3
>  ....
>  I want to have them single quoted likt this:
>  'team1'
>  'team2'
>  'team3'

awk '{a="\047" ;print a$0a}' infile > outfile

Michael Heiming
--
Remove +SIGNS and www. if you expect an answer, sorry for
inconvenience, but I get tons of SPAM



Tue, 28 Jun 2005 18:03:48 GMT  
 How to print out single quoted columns?

Quote:


> > Greetings!

> >  There is a file that contains the following.

> >  teamname

> >  team1
> >  team2
> >  team3
> >  ....

> >  I want to have them single quoted likt this:

> >  'team1'
> >  'team2'
> >  'team3'

> awk '{a="\047" ;print a$0a}' infile > outfile

To make it a little bit more efficient for big files

awk '{BEGIN {a="\047"} {print a$0a}}' infile > outfile

Regards
Juergen



Fri, 01 Jul 2005 19:23:39 GMT  
 How to print out single quoted columns?
Hi,

Quote:


> > awk '{a="\047" ;print a$0a}' infile > outfile

> To make it a little bit more efficient for big files

> awk '{BEGIN {a="\047"} {print a$0a}}' infile > outfile

you have to write:

awk 'BEGIN {a="\047"} {print a$0a}' infile > outfile

but I haven't tested this either. ;-)

Stepan



Fri, 01 Jul 2005 20:17:36 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. awk not printing single quotes

2. printing single quote (apostrophe) with awk

3. printing a single quote in awk

4. Printing single quotes

5. instead of single column, print fields 3 or 4 across then newline

6. replace single quote to double quote with an example

7. single-quoted string conversion to triple-quoted string

8. how do i convert a multi column into a single column in the output in fortran

9. Print outs of Richtext Streams

10. gawk win32 binary & single quote invalid char

11. Substituting single quotes from Perl via shell using awk and gsub

12. parsing lines with quoted strings as single fields

 

 
Powered by phpBB® Forum Software