Results 1 to 5 of 5
The purpose of this is, if Hw1 is open then echo an message, otherwise open hw2.
My code is
If [ps -ef | grep hw1]
then true
echo "hw1 is ...
- 04-13-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 7
why isn't this line working for me, bash help
The purpose of this is, if Hw1 is open then echo an message, otherwise open hw2.
My code is
If [ps -ef | grep hw1]
then true
echo "hw1 is open"
else
cat hw2
fi
- 04-14-2008 #2Linux Engineer
- Join Date
- Nov 2004
- Location
- Ft. Polk, LA
- Posts
- 796
Try it without the brackets
http://tldp.org/LDP/abs/html/testconstructs.html
- 04-14-2008 #3
because when you give a grep command it is run as a process.
so your grep hw1 is also shown in the output.
Try somethin like
ps -ef | grep hw1 | grep -v grep
means that output statements that dont have grep.
- 04-14-2008 #4Linux User
- Join Date
- Aug 2006
- Posts
- 458
- 04-14-2008 #5
You need to use some quotes:
The quotes are found using shift and the key above tabCode:If [ `ps -ef | grep hw1` ]
Linux User #453176


Reply With Quote
