/ Published in: Bash

checks for
number
character
alphanumeric
number
character
alphanumeric
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
[[ -z "$1" ]] && echo "I cant work without an input" && exit 1 INPUT="$@" [[ "$INPUT" == ?(+|-)+([0-9]) ]] && echo "$INPUT is numeric" && exit 0 [[ "$INPUT" == +([a-zA-Z]) ]] && echo "$INPUT is character" && exit 0 [[ "$INPUT" == *([0-9]|[a-zA-Z])* ]] && echo "$INPUT is alpha-numeric" && exit 0
Comments
