Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi all,
This is a simple script for some other I’m doing, but before change example1 I wanted to test with an example 2.
The code must be work this way.
./test James
Good morning James--- END./test nojames
Usage: ./test James or james.Code I have done, but Im having a hard brain fart, is this.
#!/bin/bash
name=$1if ($name != “James” -o $name != “james” ); then
echo "usage: $0 James or james"
exit 1
elseecho "Good morning $name"
fi
Don´t freak out until you know the facts...Relax...!

I already did that before, but didnt help, some other clue ?Thanks.
Don´t freak out until you know the facts...Relax...!

Also make sure that:
there is a space/blank right after [
there is a space/blank right before ]
What happens?

Great, it worked.
But, what does -a do ?... why didnt it work with -o, I had made some other codes with -o and it work ?..
Thanks Guy...
Don´t freak out until you know the facts...Relax...!

Are you familiar with boolean algebra? In shell the -a is the "and" and the -o is "or".
($name != “James” -o $name != “james”
The above reads if name is NOT James or name is NOT james, it is true. If you stop to think about it, with an "or" either [Jj]ames is still true.
Check out this link:
http://en.wikipedia.org/wiki/Boolea...click on "AND" for further info.
If you stil have trouble, try something like this:
# untested
if [ $name = "James" -o $name = "james" ]
then
:
else
echo "name is not [Jj]ames"
fi

thanks Nails.I already got some torrents for O'Reilly bash scripting.
and found some interesting links, including yours, but it will always be helpfull to post here ;)
Don´t freak out until you know the facts...Relax...!

![]() |
To Extract information fr...
|
Help with awk
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |