|
|
|
|
|
|
| Author |
Message |
Unix-Shell *nix forums beginner
Joined: 29 Mar 2005
Posts: 33
|
Posted: Tue Jul 18, 2006 2:10 pm Post subject:
How to check if a variable contains a " or ` ?
|
|
|
Hello Group,
This is related to a question I had posed a few days earlier. I am
prompting the user for an input using "read". The user can enter any
number, alphabet or special character or any combination of these.
However, if they enter a " (double-quote) or ` (back tick), I would
like to do something else.
So for example, they could enter: 41" or 2` or just " or `. How would
I check to see if the variable contains a " or `?
We have AIX 5.2 and am using ksh.
Thanks for any suggestions.
S |
|
| Back to top |
|
 |
Ed Morton *nix forums Guru
Joined: 20 Feb 2005
Posts: 1073
|
Posted: Tue Jul 18, 2006 2:36 pm Post subject:
Re: How to check if a variable contains a " or ` ?
|
|
|
Unix-Shell wrote:
| Quote: | Hello Group,
This is related to a question I had posed a few days earlier. I am
prompting the user for an input using "read". The user can enter any
number, alphabet or special character or any combination of these.
However, if they enter a " (double-quote) or ` (back tick), I would
like to do something else.
So for example, they could enter: 41" or 2` or just " or `. How would
I check to see if the variable contains a " or `?
We have AIX 5.2 and am using ksh.
Thanks for any suggestions.
S
|
case $var in
*[\`\"]* ) echo "yes!" ;;
esac
Regards,
Ed. |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Mon Dec 01, 2008 10:32 pm | All times are GMT
|
|
Personals | Per Insurance | Online Advertising | Online Advertising | Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|