In this example, I'm trying to see if the word 'local' is in /etc/hosts. Thanks
Grigsby, Garl ([EMAIL PROTECTED]) wrote: > >Are you just try to see if the file exists and is not empty? If so use the following: > >if [ -s /etc/hosts ] ; then >... >fi > >The -s checks that the file exists and has a size greater than zero. > >Garl > >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] Behalf >> Of Bob Crandell >> Sent: Wednesday, January 14, 2004 9:05 AM >> To: Eugene Linux Users Group >> Subject: [eug-lug]Conditional Bash script >> >> >> Hi, >> >> I'm trying to write a script that checks the contents of a >> file and if it's there >> skip it. >> >> Here is my test script: >> #!/bin/sh >> >> if [ 0 == grep local /etc/hosts ]; then >> echo "Been there. Done that." >> else >> echo "It's ok to do it now." >> fi >> =============================== >> It doesn't like the 'if' line but I haven't found an example >> that I can use. Grep >> returns 0 if the search phrase is found. Quotes, single or >> double doesn't change >> it, neither does parens or brackets. >> >> Thanks >> >> -- >> Assured Computing >> When you need to be sure. >> [EMAIL PROTECTED] >> www.assuredcomp.com >> Voice - 541-868-0331 >> FAX - 541-463-1627 >> Eugene, Oregon >> >> >> _______________________________________________ >> EuG-LUG mailing list >> [EMAIL PROTECTED] >> http://mailman.efn.org/cgi-bin/listinfo/eug-lug >> > >_______________________________________________ >EuG-LUG mailing list >[EMAIL PROTECTED] >http://mailman.efn.org/cgi-bin/listinfo/eug-lug > -- Assured Computing When you need to be sure. [EMAIL PROTECTED] www.assuredcomp.com Voice - 541-868-0331 FAX - 541-463-1627 Eugene, Oregon _______________________________________________ EuG-LUG mailing list [EMAIL PROTECTED] http://mailman.efn.org/cgi-bin/listinfo/eug-lug
