![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| if test statement | skooly5 | UNIX for Dummies Questions & Answers | 1 | 04-13-2008 04:32 PM |
| TAHI Test Suite 3.0.13 (IPv6 Conformance Test Tool branch) | iBot | Software Releases - RSS News | 0 | 04-06-2008 09:20 AM |
| Unix grep/test command | netmaster | UNIX for Dummies Questions & Answers | 1 | 10-09-2007 02:29 AM |
| Keithley Introduces Linux-Based RF Parametric Test Systems - Test and Measurement.com | iBot | UNIX and Linux RSS News | 0 | 07-23-2007 07:30 AM |
| Using grep in if statement | chiru_h | Shell Programming and Scripting | 3 | 09-12-2006 07:00 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Using grep in a test/if statement
Okay, well this is more or less my first attempt at writing a shell script.
Anyways, here's my code: Code:
cd ${PATH}
if [ 'grep SOME_STRING $PATH/$LOGFILE' ]
then
rm ${FILE}
./anotherScript
else
exit 1
fi
exit 1
|
| Forum Sponsor | ||
|
|
|
|||
|
For really large files all you want is a yes/no instead of reading thru the whole file.
Code:
cd ${PATH}
grep -q SOME_STRING $PATH/$LOGFILE
if [ $? -eq 0 ]
then
rm ${FILE}
./anotherScript
else
exit 1
fi
exit 0
Otherwise shamrock's code is just fine. |