Re: Check for special character
From: Alexis Huxley (ahuxley_at_gmx.net)
Date: 10/28/04
- Next message: Stephane CHAZELAS: "Re: Check for special character"
- Previous message: rakesh sharma: "Re: Please optimize this pair of sed expressions for me"
- In reply to: Smith: "Check for special character"
- Next in thread: Stephane CHAZELAS: "Re: Check for special character"
- Reply: Stephane CHAZELAS: "Re: Check for special character"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 28 Oct 2004 09:49:05 +0200
> My script accept user input into a variable USRIP.
> I only want input to have (aA-zZ or 0-9).
> How do I check that the variable USRIP doesn't has special character (e.g
> #$* @ etc etc) and only has aA-zZ and 0-9?
How about:
if ! expr "$USRIP" : '[a-zA-Z0-9]*$' > /dev/null; then
echo "bad input"
return 1 # or exit or whatever
fi
Repeat the square-bracketed term to specify at least one
occurence of one of those chars if empty input is not
acceptable.
Alexis
- Next message: Stephane CHAZELAS: "Re: Check for special character"
- Previous message: rakesh sharma: "Re: Please optimize this pair of sed expressions for me"
- In reply to: Smith: "Check for special character"
- Next in thread: Stephane CHAZELAS: "Re: Check for special character"
- Reply: Stephane CHAZELAS: "Re: Check for special character"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|