Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

AWK question

Hi,

How can I put a quote when i print using AWK?
Here is the code.

awk "{print ' $2 '}" inputfile > outputfile

I tried all variations to enclosed $2 field with single quotes.
Please help
Thanks a lot!


Comments

  • XfactorXfactor Member Posts: 343
    : Hi,
    :
    : How can I put a quote when i print using AWK?
    : Here is the code.
    :
    : awk "{print ' $2 '}" inputfile > outputfile
    :
    : I tried all variations to enclosed $2 field with single quotes.
    : Please help
    : Thanks a lot!

    You can use the printf available in awk. So something like this would work:
    awk '{printf(""%s"
    ", $1)}' inputfile > outputfile
  • marltondudemarltondude Member Posts: 32
    Hi, Thanks for the reply.. I forgot to mentioned, I would like to put SINGLE QUOTE instead of double quotes using awk, how can I do that?
    Thanks alot !

    : : Hi,
    : :
    : : How can I put a quote when i print using AWK?
    : : Here is the code.
    : :
    : : awk "{print ' $2 '}" inputfile > outputfile
    : :
    : : I tried all variations to enclosed $2 field with single quotes.
    : : Please help
    : : Thanks a lot!
    :
    : You can use the printf available in awk. So something like this would work:
    : awk '{printf(""%s"
    ", $1)}' inputfile > outputfile
    :

Sign In or Register to comment.