
Avoiding "/double-quotes in the command line
Quote:
>I have often been plagued with problems of using a " in an awk program
>invoked from the command line - eg
> awk -F: '$2 == "B" && $8 == "Y"' filename
>which under Win/Dos get well confused and effectively useless
>I thought I would share a thought that came to me at 3am this
>morning of how to avoid this by using the ~
>i.e.
> awk -F: '$2 ~ \B\ && $8 ~ \Y\' filename
>Of course this is not perfect because ~ means contains and == "..." means
>equals, but for my case this was sufficient
Don't you mean /B/ ? (Why the backslashes?)
BTW, I note that you use T-AWK (under DOS [aka, Windows]). As it turns out,
there are two possibles provided for you by Thompson:
1) You could use their Toolkit shell, which behaves a lot like Unix
csh (for better or worse...). It does get you around most of the
quoting problems.
2) They also have a gadget where you can put stuff in environment
variables and then use them on the command line. T-AWK parses
these like Unix environment vars - even if the shell is ordinary
COMMAND.COM. As a test, I just did:
C:\tmp> set foo="bar"
C:\tmp> awkw "BEGIN {print $foo}"
bar
C:\tmp>
(in a DOS window under Win98).
Note the use of double quotes (not single!) in the awk command
line so that, Unix style, the env var *does* get expanded.