[97605] in RedHat Linux List
Re: grep syntax
daemon@ATHENA.MIT.EDU (Rick L. Mantooth)
Wed Nov 4 00:18:43 1998
Date: Wed, 4 Nov 1998 00:21:05 -0600 (CST)
From: "Rick L. Mantooth" <rickdman@cyberramp.net>
To: "Robert W. Canary" <rwcanary@ohiocounty.net>
cc: redhat-list@redhat.com
In-Reply-To: <363FDCCB.265E@ohiocounty.net>
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com
Robert,
Welcome to the crowd ;)
The "space" in your EXCEPTIONS variable is getting eaten by grep.
Also for multiple "greps" I recommend egrep.
Try this (caution, quickie)
#!/bin/sh
#
EXCEPTIONS="ttyC4 ttyC5"
cd /var/lock ; ls tty?? | egrep -v "`echo ${EXCEPTIONS} | sed 's/ /\|/g'`"
The sed statement swaps the spaces for | due to egrep syntax :
ls | egrep -v "ttyC4|ttyC5|ttyC6" #etc...
Have fun,
Rick
On Tue, 3 Nov 1998, Robert W. Canary wrote:
> Hi,
>
> I am trying find the correct syntax for grep a directory and excluding
> certain files from the output.
>
> EXCEPTIONS="ttyC4 ttyC5"
>
> command ls /var/lock | grep tty[SC] | {filter out $EXCEPTIONS}
>
> I can filter out the exception with "grep -v ttyC4 | grep -v ttyC0", but
> I need to be able to feed it a variable that contians a list of some
> sort.
>
> thanks in advance :-)
> --
> robert
>
>
S-RIP material deleted
--
Rick L. Mantooth rickdman@cyberramp.net
http://www.cyberramp.net/~rickdman
I support Co-Ed Naked Shell Scripting
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com http://archive.redhat.com
To unsubscribe: mail redhat-list-request@redhat.com with
"unsubscribe" as the Subject.