Home > Archive > AWK > September 2006 > Pattern match description
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Pattern match description
|
|
| Cliff Sobchuk 2006-09-27, 6:56 pm |
| Hi folks, I am trying to install PDL (perl data language) and PGPLOT on
windows and the install script of PGPLOT has an awk pattern match that is
failing and I don't understand why it is failing, because I have never seen
this form in a pattern match.
here is the relevant section of the sh script, the error and the pattern
match that I would like to understand what is happening.
=====================Script portion================================
# Get a list of driver names.
DRIV_LIST=`awk '/^[^!]/{printf("$%s\n", $1)}' drivers.list | sort | uniq`
echo "Found drivers `echo $DRIV_LIST | sed 's/\\\$//g'`"
=====================Output portion================================
sh-2.04$ awk '/^[^!]/{printf("$%s\n", $1)}'
gawk: cmd. line:1: C:/Program Files/MinGW/^[^!]/{printf("$%s/n", $1)}
gawk: cmd. line:1: ^ syntax error
gawk: cmd. line:1: C:/Program Files/MinGW/^[^!]/{printf("$%s/n", $1)}
gawk: cmd. line:1: ^ syntax error
gawk: cmd. line:1: fatal: Invalid regular expression: /{printf("$%s/
=====================Pattern Match portion===========================
awk '/^[^!]/
-> the 1st ^ I know is the beginning line anchor,
-> the [ I know is the group class,
-> the 2nd ^ I know is the exclude the following tag
-> What is the ! for?
-> it looks like it is searching for lines that don't begin with something -
but I don't know what that something is...
Thanks, Cliff.
| |
| Jon LaBadie 2006-09-27, 6:56 pm |
| Cliff Sobchuk wrote:
> Hi folks, I am trying to install PDL (perl data language) and PGPLOT on
> windows and the install script of PGPLOT has an awk pattern match that is
> failing and I don't understand why it is failing, because I have never seen
> this form in a pattern match.
>
> here is the relevant section of the sh script, the error and the pattern
> match that I would like to understand what is happening.
>
> =====================Script portion================================
> # Get a list of driver names.
>
> DRIV_LIST=`awk '/^[^!]/{printf("$%s\n", $1)}' drivers.list | sort | uniq`
>
> echo "Found drivers `echo $DRIV_LIST | sed 's/\\\$//g'`"
>
> =====================Output portion================================
> sh-2.04$ awk '/^[^!]/{printf("$%s\n", $1)}'
> gawk: cmd. line:1: C:/Program Files/MinGW/^[^!]/{printf("$%s/n", $1)}
> gawk: cmd. line:1: ^ syntax error
> gawk: cmd. line:1: C:/Program Files/MinGW/^[^!]/{printf("$%s/n", $1)}
> gawk: cmd. line:1: ^ syntax error
> gawk: cmd. line:1: fatal: Invalid regular expression: /{printf("$%s/
>
> =====================Pattern Match portion===========================
> awk '/^[^!]/
> -> the 1st ^ I know is the beginning line anchor,
> -> the [ I know is the group class,
> -> the 2nd ^ I know is the exclude the following tag
> -> What is the ! for?
> -> it looks like it is searching for lines that don't begin with something -
> but I don't know what that something is...
>
> Thanks, Cliff.
>
>
Looks like the driver list might be something like:
driver1 ...
driver2 ...
!driver3 ...
driver4 ...
Where a leading ! is being used to say 'don't install', or 'exclude' this driver.
The pattern is just looking for lines that start with other than '!'
| |
| Ed Morton 2006-09-27, 6:56 pm |
| Cliff Sobchuk wrote:
> Hi folks, I am trying to install PDL (perl data language) and PGPLOT on
> windows and the install script of PGPLOT has an awk pattern match that is
> failing and I don't understand why it is failing, because I have never seen
> this form in a pattern match.
>
> here is the relevant section of the sh script, the error and the pattern
> match that I would like to understand what is happening.
>
> =====================Script portion================================
> # Get a list of driver names.
>
> DRIV_LIST=`awk '/^[^!]/{printf("$%s\n", $1)}' drivers.list | sort | uniq`
>
> echo "Found drivers `echo $DRIV_LIST | sed 's/\\\$//g'`"
>
> =====================Output portion================================
> sh-2.04$ awk '/^[^!]/{printf("$%s\n", $1)}'
> gawk: cmd. line:1: C:/Program Files/MinGW/^[^!]/{printf("$%s/n", $1)}
> gawk: cmd. line:1: ^ syntax error
> gawk: cmd. line:1: C:/Program Files/MinGW/^[^!]/{printf("$%s/n", $1)}
> gawk: cmd. line:1: ^ syntax error
> gawk: cmd. line:1: fatal: Invalid regular expression: /{printf("$%s/
>
> =====================Pattern Match portion===========================
> awk '/^[^!]/
> -> the 1st ^ I know is the beginning line anchor,
> -> the [ I know is the group class,
> -> the 2nd ^ I know is the exclude the following tag
> -> What is the ! for?
> -> it looks like it is searching for lines that don't begin with something -
> but I don't know what that something is...
Hmm, now what COULD that "!" be for :-;? It's SOMETHING all right.....
As for the error output, this looks a tad suspicious:
[color=darkred]
Notice that your awk command used a back-slash for it's newline in the
printf (i.e. "\n") but your error output magically changed that to a
forward slash (i.e. "/n"). Run the command again and this time post
exactly the copy-pasted command plus output plus sample input.
Also, in general when you see apparently mangled output, check your
source code and input files for control characters like those pesky
control-Ms that MS loves to splash around.
Ed.
| |
| cliff_nn 2006-09-28, 6:56 pm |
|
Ed Morton wrote:
> Cliff Sobchuk wrote:
>
>
> Hmm, now what COULD that "!" be for :-;? It's SOMETHING all right.....
>
> As for the error output, this looks a tad suspicious:
>
>
> Notice that your awk command used a back-slash for it's newline in the
> printf (i.e. "\n") but your error output magically changed that to a
> forward slash (i.e. "/n"). Run the command again and this time post
> exactly the copy-pasted command plus output plus sample input.
>
> Also, in general when you see apparently mangled output, check your
> source code and input files for control characters like those pesky
> control-Ms that MS loves to splash around.
>
> Ed.
Thanks Gentlemen. Apparently my newsfeed at work is not updated very
regularly. I just created a google account so that I could reply.
I didn't even see that the \n became /n. Good catch. I can't seem to
get the command line to function correctly. I can't seem to get awk to
function properly in the mingw environment. I'll send an email to the
mingw folks to see if they understand why awk doesn't like the ":" in
the path and translates the \n to a /n.
Thank, Cliff.
And yes the drivers not to install are preceeded by the ! (Doh!).
| |
| cliff_nn 2006-09-28, 6:56 pm |
|
Ed Morton wrote:
> Cliff Sobchuk wrote:
>
>
> Hmm, now what COULD that "!" be for :-;? It's SOMETHING all right.....
>
> As for the error output, this looks a tad suspicious:
>
>
> Notice that your awk command used a back-slash for it's newline in the
> printf (i.e. "\n") but your error output magically changed that to a
> forward slash (i.e. "/n"). Run the command again and this time post
> exactly the copy-pasted command plus output plus sample input.
>
> Also, in general when you see apparently mangled output, check your
> source code and input files for control characters like those pesky
> control-Ms that MS loves to splash around.
>
> Ed.
Thanks Gents,
Didn't even realize the \n to /n translation.
and Yes, the script is looking for the "!" to exclude those drivers
(Doh!)
Weird. Even my replies via the groups weren't getting posted.
Anyway I found out the issue - very wierd. Since I have both the minGW
and the GnuWin32 tools loaded, the gawk that was being called was
actually the one in the GnuWin32 path and not the minGW path. Haven't
figured why yet, but I manually changed the name and it magically
works. Apparently the minGW and GnuWin32 implementations are different
due to the shell that is used (sh versus command.com).
Thanks, Cliff.
|
|
|
|
|