Menu

Backslash in Gawk

Help
2006-09-09
2012-07-26
  • porzeraczmuzguw

    porzeraczmuzguw - 2006-09-09

    Hi

    How can I use backslash in Gawk in windows command line? Is it possible without using hex values?

    C:\temp\gawk\bin>gawk "$1 == \"\\"" s\bbs-list
    gawk: cmd. line:1: $1 == "\"
    gawk: cmd. line:1: ^ unterminated string

    Maybe is there a way to use ' to enclose program listing? (ordinary way doesn't work:

    C:\temp\gawk\bin>gawk '$1 == "\"' s\bbs-list
    gawk: cmd. line:1: '$1
    gawk: cmd. line:1: ^ invalid char ''' in expression

    )

    Now I have to use something like this:

    C:\temp\gawk\bin>gawk "$1 == \"\x5C\"" s\bbs-list
    \ 888-8888

     
    • Kees Zeelenberg

      Kees Zeelenberg - 2006-09-09
       
    • porzeraczmuzguw

      porzeraczmuzguw - 2006-09-09

      Thanks, but I can't find anything that would help me in this case :(.

       
    • porzeraczmuzguw

      porzeraczmuzguw - 2006-09-09

      Sorry, [AB] works, but [A-Z] gives me strange and wrong results:

      Rekord = a RT = rekord
      Rekord = 1 a RT = AAAAA
      Rekord = a RT = rekord
      Rekord = 2 a RT = BBBBB
      Rekord = a RT = rekord
      Rekord = 3 a RT =

       
    • porzeraczmuzguw

      porzeraczmuzguw - 2006-09-09

      Also, I found that this example from manual doesn't work for me:

      $ echo rekord 1 AAAA rekord 2 BBBB rekord 3 |
      > gawk 'BEGIN { RS = "\n|( [[:upper:]]+ )" }
      > { print "Rekord =", $0, "a RT =", RT }'

      When put in seperate file (to avoid problems with quotations) and ran with -f I get:

      C:\temp\gawk\bin>gawk -f s\test.txt
      gawk: s\test.txt:1: fatal error: internal error

      This application has requested the Runtime to terminate it in an unusual way.
      Please contact the application's support team for more information.

      I found that "[[:upper:]]" is a problem - when replaced with [A-Z] it works. [:upper:] works in other cases... I also found that when I replace "[[:upper:]]" with "[:upper:]" error does not appear.

       
MongoDB Logo MongoDB