When I tried to run your command at first I got the error:
awk: '/DoLabelQuery\(self\)/
awk: ^ invalid char ''' in expression
'/QName\[[[[:digit:]][[[:digit:]]]/' is not recognized as an internal or external command,
operable program or batch file.
'/QName\[[[[:digit:]]]/' is not recognized as an internal or external command,
operable program or batch file.
'/' is not recognized as an internal or external command,
operable program or batch file.
'/endMethod/' is not recognized as an internal or external command,
operable program or batch file.
'/endmethod/' is not recognized as an internal or external command,
operable program or batch file.
'/add\' is not recognized as an internal or external command,
operable program or batch file.
'/' is not recognized as an internal or external command,
operable program or batch file.
which makes it seem that all the parts of the awk
script are being parsed as separate words and many of them are then being processed as though they are commands after ||
. This is because, as this SO question shows single quotes aren't really quotes in Windows cmd shell, as they are in (most?) linux shells. cmd uses only double quotes, which fortunately works fine for this command it seems, so the solution here is to use:
awk "/DoLabelQuery\(self\)/||/QName\[[[[:digit:]][[[:digit:]]]/||/QName\[[[[:digit:]]]/ || /;BUTTON =/ || /endMethod/ || /endmethod/ || /add\(/ || /;CODE = /" HELLO.fsl > x.txt
though I would expect putting the commands into a file and using it that way should work as well.
What happens when you try running it? Can you give us some sample input to test with? Does it have to be
awk
? If you just want matched lines to be printed,grep
seems like a good tool for the job – Eric Renouf – 2017-08-15T17:06:38.350Using
gawk-3.1.6
for win32 I got your command to work if I just used double quotes instead of single quotes, does that work for you? – Eric Renouf – 2017-08-15T17:22:11.630Using double quotes didn't give me an error but it yield a result with zero bytes. The input file is a binary form with islands of ASCII that we are trying to target. Kind of hard to give you that. Can you show me any similar Windows awk example where a file is used to supply the awk commands? I can['t seem to find that using Google. – Peter Dixon – 2017-08-15T17:53:23.587
What are you using for
awk
on Windows? I get a line of output if I do, for example:gawk "/cannot be run in DOS/" awk.exe
so thatgawk
with double quotes can process binary files and find ascii within them – Eric Renouf – 2017-08-15T17:56:27.670The issue does seem to be related to running on a binary file. If I strip out the control characters the commands seem to work ok, or at least a simplified version of it does. I'm using the most recent version of awk/gawk from http://gnuwin32.sourceforge.net/packages/gawk.htm.
– Peter Dixon – 2017-08-15T18:10:26.927Decided to go with Window's FINDSTR command. It seems to be less problematic that awk on the Windows platform. It's too bad, because on Linux awk worked perfectly well. Unfortunately this app has to run end to end on Windows. – Peter Dixon – 2017-08-15T18:33:45.730