[PLUG] awk script
Michael Montagne
montagne at boora.com
Thu Sep 26 20:52:39 UTC 2002
>On 26/09/02, from the brain of mikeraz at patch.com tumbled:
> Ooops, see correction.
>
> On Thu, Sep 26, 2002 at 01:11:32PM -0700, mikeraz at patch.com typed:
> > You might try:
> >
> >
> > #!/bin/bash
> > NAME=$1
> > # some error checking to be sure a name was passed in...
> > /bin/awk "BEGIN {IGNORECASE=1}; ($15 ~/$NAME/) {print $1 $2 " " $3 " " $12}" /var/log/mail.log
>
> /bin/awk "BEGIN {IGNORECASE=1}; (\$15 ~/$NAME/) {print \$1 \$2 " " \$3 " " \$12}" /var/log/mail.log
>
> >
> > Note, the double quote for the AWK program, single quotes won't allow the $NAME to be expanded
Thanks guys, this is what I ended up with:
Pretty cool I think.
#!/bin/bash
#variable definitions
username=$1
awk "BEGIN {IGNORECASE=1}; (\$15 ~/$username/) {print \$1 \$2 \" \" \$3 \" \" \$12}" mail.log>$username.txt
#End Script
Don's worked too once I escaped all the $s. You guys are a great
resource. Now I'm off to show off my new tool
--
Michael Montagne [montagne at boora.com] 503.226.1575
--
More information about the PLUG
mailing list