bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (no subject)


From: Bob Proulx
Subject: Re: (no subject)
Date: Tue, 5 Oct 2004 22:13:17 -0600
User-agent: Mutt/1.3.28i

Carlson, Doug wrote:
> I recently downloaded your gnuwin32 version of gawk.

Strictly speaking the gnuwin32 is a port of the GNU version of awk to
another non-gnu operating system.  And I mention this because it has
bearing on your current problem.

> However, whenever
> I was attempting to run commands with it, I was repeatedly getting
> syntax errors.  After repeated efforts to rectify this issue, I have
> come to the conclusion that I'm either a complete retard and I'm missing
> something obvious, or else there is a bug with the program.  Below is an
> example of the output that I am receiving when I run the command from
> cmd.  Can someone clear up whether this is a bug or if its user error?
> At this point, the program is unusable. 
> 
> D:\Program Files\GnuWin32\bin>gawk '/Why not working/ { print $1 }'
> 
> Gawk: cmd. Line:1: '/Why
> Gawk: cmd.line:1: ^ invalid char ''' in expression

On GNU and UNIX-like systems the shell parses command line arguments
into strings.  The quotes available to use there are both single and
double quotes.  The difference is that single quotes are (mostly)
verbatim while double quotes have $variables expanded within them.  So
normally one would use '/PATTERN/{ print $1 }' on the command line so
that the $1 is not expanded by the shell but is passed to the command.

You are using this on a non-native system.  It is a port of the
program.  The documentation is for the native system and not the
port.  On your system the quotes are, if I recall correctly, only the
double quote variety and $variables do not exist to be expanded
there.  So you need to mentally translate the documentation from
single quotes to double quotes.  Don't take that as completely
authoritative since I don't use MS-Win systems and don't know much
about them.  But I think that is your problem.

On MS-DOS systems it is usually required to place the program in a
separate file and to call it from your batch script using the -f
option.  If I recall correctly you are limited to 128 characters on
the command line too.  So putting the program in a file is often
needed to avoid that limit for more than trivial things.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]