![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2008
Posts: 2
Rep Power: 0
![]() |
if condition and grep
hey all
im trying to write a script, need some help concept goes like this: i want to grep a file for a word/phrase, and depending on grep's output (basically, any output at all = found, NULL = not found) to do -something-. basically, in pseudocode: if(grep_output == NULL):
echo "not found";
else:
echo "found" |
|
|
|
|
|
#2 |
|
Newbie
Join Date: May 2008
Posts: 2
Rep Power: 0
![]() |
Re: if condition and grep
okay, figured it out.
grep_output=`grep <word> <file>`
if [ "$grep_output" == "" ]; then
echo "not found";
else
echo "found";
fi |
|
|
|
|
|
#3 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 630
Rep Power: 4
![]() |
Re: if condition and grep
bash Syntax (Toggle Plain Text)
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|