case $* in
*@*) echo "at";;
*) echo "no-at";;
esac
-s
--
Copyright 2009, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
You've already seen a solution in this thread that is proposing
to use a 'case' statement.
In case you want to use the above if-construct; omit the quotes
so that the stars will not be taken literally...
if [[ $* == *@* ]]
Janis
> I know how to do exact matches but how do I do a partial match?
>
> TIA
>
>
>
>
From the bash man page:
[[ expression ]]
(first paragraph omitted)
When the == and != operators are used, the string to the
right of the operator is considered a pattern and matched
according to the rules described below under Pattern Matching.
If the shell option nocasematch is enabled, the match is
performed without regard to the case of alphabetic characters.
The return value is 0 if the string matches (==) or does not
match (!=) the pattern, and 1 otherwise. Any part of the
pattern may be quoted to force it to be matched as a string.
That last sentence explains why your sample code didn't work. You've
quoted your pattern, so it's matched as the literal string (an asterisk
followed by an @, followed by another asterisk), rather than a pattern.
Remove the single quotes around your pattern and see how it does.
-Greg
--
::::::::::::: Greg Andrews ::::: ge...@panix.com :::::::::::::
I have a map of the United States that's actual size.
-- Steven Wright