Posted By

yoblob on 02/24/11


Tagged

Bash


Versions (?)

check type of input


 / Published in: Bash
 

checks for number character alphanumeric

  1. [[ -z "$1" ]] && echo "I cant work without an input" && exit 1
  2.  
  3.  
  4. [[ "$INPUT" == ?(+|-)+([0-9]) ]] && echo "$INPUT is numeric" && exit 0
  5.  
  6. [[ "$INPUT" == +([a-zA-Z]) ]] && echo "$INPUT is character" && exit 0
  7.  
  8. [[ "$INPUT" == *([0-9]|[a-zA-Z])* ]] && echo "$INPUT is alpha-numeric" && exit 0

Report this snippet  

You need to login to post a comment.