Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2009
    Posts
    6

    Post Unanswered: How i can print single quota in awk print command

    I have the follow command

    ls -l | grep 'Feb 21' | awk '{print "awk /SESSIONID:/ {print $0} "$9 ">> join.file" }'> a.a

    The commando run sucessfully

    But i need put single quota in print

    Like that

    ls -l | grep 'Feb 21' | awk '{print "awk '/SESSIONID:/ {print $0}' "$9 ">> join.file" }'> a2.a

    and begin '/SESSIONID
    and the end $0}'

    But if i try run this command.. i have an error

    oracle [Amadeus1]% ls -l | grep 'Feb 21' | awk '{print "awk '/SESSIONID:/ {print $0}' "$9 ">> join.file" }'> a2.a
    awk: Cannot find or open file {print.

    The source line number is 1.
    oracle [Amadeus1]%


    how i can put this single quota in awk print command

    Thanks

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    did your other question this morning get answered fully?

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Escape the single quote inside the AWK script:
    Code:
    awk '{ ... \' ... }'
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    Feb 2009
    Posts
    6

    Dont work

    I apply your recomendation but, dont work

    When i executed, dont do it anything.


    % ls -l | awk '{print "awk \'/SESSIONID:/ {print $0}\' "$9 ">> join.file" }'> a.a
    >
    >
    >ctrol +C
    %

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Then you can use the hex code point for the character (assuming you use ASCII/UTF-8):
    Code:
    awk '{print "\x27" $0; }'
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  6. #6
    Join Date
    Feb 2009
    Posts
    6

    Red face dont work again

    I try but dont work

    oracle [Amadeus1]% ls -l | awk '{print "awk \x27/SESSIONID:/ {print $0}\x27 "$9 ">> join.file" }'> a.a
    awk x27/SESSIONID:/ {print $0}x27 ora_1000038.aud>> join.file
    awk x27/SESSIONID:/ {print $0}x27 ora_1000691.aud>> join.file
    awk x27/SESSIONID:/ {print $0}x27 ora_1000736.aud>> join.file
    awk x27/SESSIONID:/ {print $0}x27 ora_1000808.aud>> join.file
    awk x27/SESSIONID:/ {print $0}x27 ora_1000935.aud>> join.file

    put x27 when must be put '

    Any other idea.

    Regards.

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    It works fine for me:
    Code:
    $ awk '{print "\x27" $0; }' < /etc/resolv.conf
    '### /etc/resolv.conf file autogenerated by netconfig!
    '#
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  8. #8
    Join Date
    Feb 2009
    Posts
    6

    Red face Dont work

    My S.O is Tru 64 unix.

    Regards,

  9. #9
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Then check if you have GNU awk installed - maybe it is named "gawk"?
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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