I would stick to kbob's suggestion for this task and verify that the return value is 0.
This snippet checks to see that the return value is not 1, which is the value you'll get if the file doesn't contain the search string and you have perms to read the file. However, failures for different reasons will return different return values. Consider: [dumpster]$ id -p uid jason groups staff admin [dumpster]$ ls -l notmine -rw------- 1 root staff 6 Jan 14 20:18 notmine [dumpster]$ grep local notmine grep: notmine: Permission denied [dumpster]$ echo $? 2 [dumpster]$ With many tasks, it's better to do positive validation (i.e. verifying what you want actually happened) than negative validation (trying to verify all the things you didn't want didn't happen). Jason Bob C wrote: >I've seen that before. I didn't realize that's >what it did. > >Look mom, I'm a programmer. > >Thanks > >Grigsby, Garl ( [EMAIL PROTECTED] ) wrote: > >#!/bin/sh > >grep local /etc/hosts > /dev/null > >if [ $? -ne 1 ] > then > echo "Been there. Done That." > else > echo "It's ok to do it now." >fi > __________________________________ Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes http://hotjobs.sweepstakes.yahoo.com/signingbonus _______________________________________________ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug
