Re: OT: Which tool, and how, to get partial string from file?
On Sat, Aug 21, 2004 at 10:16:26AM -0500, Kent West wrote:
> How do I test to make sure the name is in two files? Like so?
>
> if ( ! grep -q '\<tuber\>' /etc/passwd ) or ( ! grep -q '\<tuber\>'
> /etc/shadow )
> then
> echo "Error: One or both files are missing 'tuber'" | mail root
> exit 1
> fi
Almost. I'm pretty sure there is no 'or', you have to use ||.
if ( ! grep -q '\<tuber\>' /etc/passwd ) || ( ! grep -q '\<tuber\>'
/etc/shadow )
then
echo "Error: One or both files are missing 'tuber'" | mail root
exit 1
fi
Note that the parens are probably unneccesary, but IMO they improve
readability.
Reply to:
- References:
- OT: Which tool, and how, to get partial string from file?
- From: Kent West <westk@acu.edu>
- Re: OT: Which tool, and how, to get partial string from file?
- From: "Miquel van Smoorenburg" <miquels@cistron.nl>
- Re: OT: Which tool, and how, to get partial string from file?
- From: Kent West <westk@acu.edu>
- Re: OT: Which tool, and how, to get partial string from file?
- From: Kent West <westk@acu.edu>
- Re: OT: Which tool, and how, to get partial string from file?
- From: Kent West <westk@acu.edu>
- Re: OT: Which tool, and how, to get partial string from file?
- From: Kent West <westk@acu.edu>
- Re: OT: Which tool, and how, to get partial string from file?
- From: Stefan O'Rear <stefanor@cox.net>
- Re: OT: Which tool, and how, to get partial string from file?
- From: Kent West <westk@acu.edu>
- Re: OT: Which tool, and how, to get partial string from file?
- From: Kent West <westk@acu.edu>