niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » shell
How to check if a variable contains a " or ` ?
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
Ed Morton
*nix forums Guru


Joined: 20 Feb 2005
Posts: 1073

PostPosted: Tue Jul 18, 2006 2:36 pm    Post subject: Re: How to check if a variable contains a " or ` ? Reply with quote

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
Unix-Shell
*nix forums beginner


Joined: 29 Mar 2005
Posts: 33

PostPosted: Tue Jul 18, 2006 2:10 pm    Post subject: How to check if a variable contains a " or ` ? Reply with 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
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Fri Nov 21, 2008 10:55 pm | All times are GMT
navigation Forum index » Programming » shell
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Postfix + MySQL error: very strange variable %s iWarior Postfix 0 Mon Aug 25, 2008 2:01 pm
No new posts User Environment - export PATH variable paalepu AIX 0 Tue Sep 12, 2006 8:12 pm
No new posts Force linker to check all the implementation toton C++ 1 Thu Jul 20, 2006 6:08 am
No new posts Qmail / SpamControl => Check if DNS exist ? Phibee NOC Qmail 2 Thu Jul 20, 2006 4:51 am
No new posts how to alias an array with a variable in a loop ? Jack Perl 4 Wed Jul 19, 2006 8:17 pm

Coches | Repair Bad Credit | Free Ipod Nano | Israel Perry | Credit Reports
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
[ Time: 0.4514s ][ Queries: 20 (0.3472s) ][ GZIP on - Debug on ]