Re: Writing a script that looks for missing data

From: Alan Connor (zzzzzz_at_xxx.yyy)
Date: 03/31/04


Date: Tue, 30 Mar 2004 23:49:41 GMT

On 30 Mar 2004 13:04:57 -0800, Ludwig77 <gregrjones@yahoo.com> wrote:
>
>
> Alan Connor <zzzzzz@xxx.yyy> wrote in message news:<cmgac.8312$lt2.1196@newsread1.news.pas.earthlink.net>...
>> On 30 Mar 2004 06:41:00 -0800, Ludwig77 <gregrjones@yahoo.com> wrote:
>> >
>> >
>> > I'm trying to write a script that will execute an action if a piece of
>> > data is missing from a flat file.
>> >
>> > Here is what I have so far:
>> >
>> > (for j in "data1" "data2" "data3"
>> > do
>> > egrep $j flat_file
>> >
>> > I'm stuck with how to test if the $j variable is NOT in the flat_file.
>> >
>> > I'm attempting this in Linux
>>
>> if ! egrep "$j" ...... ; then ........ ; else ...... ; fi
>>
>> The "!" means "no".
>>
>>
>>
>> AC
>
> The solution that I found uses Exit values:
>
> do
> egrep $j output2_$$ > /dev/null
> if [ $? = 1 ]
> then
> do some action
> fi
> done)

I believe that

if ! grep...

does just that.

What else would it do?

The results are identical.

AC