1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to? Advanced quoting (for awk)

Discussion in 'Support' started by gschizas, Nov 13, 2013.

  1. gschizas

    Joined:
    May 30, 2008
    Messages:
    81
    Likes Received:
    0
    I'm trying to do this:

    (from bash)


    Code:
    svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > authors-transform.txt
    As you can see, it uses advanced quoting, with multiple quotes, some of which are not really usable from Windows and TCC.

    I'm sure I can do the same thing using simple TCC commands, but I'd like this to run first to be able to replicate the whole functionality.

    I've gotten so far:

    Code:
    svn log -q | awk -F "|" "/^r/ {sub(\"^ \", \"\", $2); sub(\" $\", \"\", $2); print $2\" = \"$2\" ^<\"$2\"^>\"}"
    This uses double quotes (because Windows, apparently) and \" to escape the quotes (I have no idea who does this - I'd guess TCC, but I've never seen escaping a quote with "\" before.

    This unfortunately outputs
    Code:
    user = user ^<user^>
    instead of
    Code:
    user = user <user>
    If I don't use the escape for the redirection characters (< and >), I get

    Code:
    TCC: (Sys) Access is denied.
     "C:\}"
    It would seem that you're damned if you do, damned if you don't with this.

    I'll do it another way (I'm sure that @WORD will come in handy here), but the real question is, how can you pass the proper second parameter to awk?
     
  2. w_krieger

    Joined:
    Nov 2, 2008
    Messages:
    176
    Likes Received:
    0
    Could you put the awk argument into a cmd file, and run awk -f something?

    Many years ago, JPSoftware was pushing rexx for its advanced string handling.
     
  3. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    George:
    Take a look at the various enable / disable codes of SETDOS /X. It might to the job for you; once you change the mask it is in effect for all commands until restored with another SETDOS command, and is part of the command stream. Also look at the TEXT / ENDTEXT block, which allows any character within the block, but is just text output to STDOUT (redirectable). The ECHOX command does the same for its parameters (i.e., the rest of its command line). If the command line is known when you write your batch file (i.e., not dynamically built) one of these techniques might be all you need. OTOH if you need to build the AWK command dynamically, Wendy's suggestion (build your command in a file) can help; the "binary buffer" method allows you to put anything in a file (albeit laboriously).
     

Share This Page