Find the answer to your Linux question:
Results 1 to 3 of 3
How the hell can i use " as s delimiter in AWK command? I have Code: less adrian-rhymes.html | grep '<a href=' |grep 'http://media.ebaumsworld.com/' | awk 'BEGIN { FS = ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Newbie
    Join Date
    Dec 2005
    Posts
    104

    Awk Fs = "


    How the hell can i use " as s delimiter in AWK command?

    I have
    Code:
    less adrian-rhymes.html | grep '<a href=' |grep  'http://media.ebaumsworld.com/' | awk 'BEGIN { FS = "[g]" } ; { print $2 }'
    And it accepts g as a delimiter
    But

    Code:
    less adrian-rhymes.html | grep '<a href=' |grep  'http://media.ebaumsworld.com/' | awk 'BEGIN { FS = "["]" } ; { print $2 }'
    Gives me this:

    Code:
    awk: cmd. line:1: BEGIN { FS = "["]" } ; { print $2 }
    awk: cmd. line:1:                 ^ parse error
    awk: cmd. line:1: BEGIN { FS = "["]" } ; { print $2 }
    awk: cmd. line:1:                  ^ unterminated string
    Cheers.
    NAthan

  2. #2
    Linux Guru sdousley's Avatar
    Join Date
    Feb 2004
    Posts
    1,790
    Running it from a command line you will have to "escape" the " like:

    Code:
    less adrian-rhymes.html | grep '<a href=' |grep  'http://media.ebaumsworld.com/' | awk 'BEGIN { FS = "[\"]" } ; { print $2 }'
    The \" treats it as a string: " rather than a start quote
    "I am not an alcoholic, alcoholics go to meetings"
    Registered Linux user = #372327

  3. #3
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    alternatively -
    Code:
    ... | awk -F\" '{print $2}'

  4. $spacer_open
    $spacer_close

Posting Permissions

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