Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Unanswered: nawk - Print Single Quote

    I would like to know how to print a single quote in nawk ...

    Eg:

    echo myname | nawk '{print $1}'

    The output should be
    'myname'
    (the word myname within single quotes)

    I have tried a couple of alternatives, but have not been successful ...

    Thanks in advance ...

    Cheers
    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  2. #2
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    I cheat...

    echo hello | awk -v quote=\' '{print quote $1 quote}'

    I should imagine that would work for nawk also.

    Damian

  3. #3
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Thanks ... It works

    Sathyaram

    Originally posted by Damian Ibbotson
    I cheat...

    echo hello | awk -v quote=\' '{print quote $1 quote}'

    I should imagine that would work for nawk also.

    Damian
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  4. #4
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    If you can modify your input to awk, you could of course also do...

    echo \'hello\' | awk '{print $1}'

    Damian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •