readded udpated scripts directory
This commit is contained in:
parent
cd053a412a
commit
f3117c81d9
84 changed files with 3210 additions and 0 deletions
33
scripts/valida1num
Executable file
33
scripts/valida1num
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
# validAlphaNum--Ensures that input consists only of alphabetical
|
||||
# and numeric characters
|
||||
|
||||
validAlphaNum()
|
||||
{
|
||||
# Validate arg: returns 0 if all upper+lower+digits; 1 otherwise
|
||||
|
||||
# Remove all unacceptable chars.
|
||||
validchars="$(echo $1 | sed -e 's/[^[:alnum:]]//g')"
|
||||
|
||||
if [ "$validchars" = "$1" ] ; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# BEGIN MAIN SCRIPT--DELETE OR COMMENT OUT EVERYTHING BELOW THIS LINE IF
|
||||
# YOU WANT TO INCLUDE THIS IN OTHER SCRIPTS.
|
||||
# =================
|
||||
/bin/echo -n "Enter input: "
|
||||
read input
|
||||
|
||||
# Input validation
|
||||
if ! validAlphaNum "$input" ; then
|
||||
echo "Please enter only letters and numbers" >&2
|
||||
exit 1
|
||||
else
|
||||
echo "Input is valid."
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue