Re: If with multiple greps
From: William Park (opengeometry_at_yahoo.ca)
Date: 12/02/03
- Next message: Francis: "Re: alias in tcsh"
- Previous message: yls177: "Re: change /oracle to alter /oracle in a file with :%s issues"
- In reply to: greyfell_at_zerobyte.org: "If with multiple greps"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 2 Dec 2003 06:24:50 GMT
greyfell@zerobyte.org wrote:
> I would like to use an if with more than one grep in it. Basically, I
> have this statement that works:
>
> if grep -F -q "$ALIASIP " /etc/hosts
>
> I would like to make it compound so that either of two greps will
> result in a true and drop into the then. I'd like to do basically...
>
> if [ `grep -F -q "$ALIASIP " /etc/hosts` -o `grep -F -q "$ALIASIP\t"
> /etc/hosts` ]
>
> That doesn't seem to work, though. It always tests true, and I'm not
> quite certain why. I know other ways I can get this to work, but if I
> keep falling back on the proverbial long way around, I'll never get
> any better at this. Any help appreciated.
Since your logic is OR,
if grep -F -e "aaa" -e "bbb" ... ; then ... ; fi
Also, you can write the patterns to a file, and
if grep -F -f file ; then ... ; fi
-- William Park, Open Geometry Consulting, <opengeometry@yahoo.ca> Linux solution for data management and processing.
- Next message: Francis: "Re: alias in tcsh"
- Previous message: yls177: "Re: change /oracle to alter /oracle in a file with :%s issues"
- In reply to: greyfell_at_zerobyte.org: "If with multiple greps"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|