Results 1 to 3 of 3
Hello all. This will be my first post. I need some help with this simple --if statement.
I'm writing a program that needs a test statement to test if the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 03-12-2013 #1Just Joined!
- Join Date
- Jul 2012
- Posts
- 5
Test statement in bash
Hello all. This will be my first post. I need some help with this simple --if statement.
I'm writing a program that needs a test statement to test if the user selected file is the same as the program being executed. And if it is not, remove it. The name of the program is job06.
This gives an error...
if [ "$file" ! -e "job06" ] # line 25
then
echo "$file" " has been removed."
rm "$file"
fi
The error is...
./job06: line 25: [: too many arguments
- 03-12-2013 #2Linux Newbie
- Join Date
- Nov 2012
- Posts
- 134
hi,
-e stands for file (file or directory) exists.
lexical equality is simple = (equal sign)
see:Code:help test
- 03-14-2013 #3
This does not have "test" statement but does the same thing.
Code:if [ $(whoami) != "job06" ] then echo "job06 must be run by job06, aborting" exit 0 fi


Reply With Quote
