Unix script to analyze the input, depending on the type of character -


i having time script here

  1. the script reads character keyboard.
  2. depending on type of character, script displays 1 of following messages

uppercase letter lowercase letter digit special character.

#!/bin/bash echo 'enter single character:' read $1 if $1 = "a-z"   echo 'uppercase letter' fi  if $1 = "a-z"   echo 'lowercase letter' fi  if $1 = [ ! @ $ ^ & * ~ ? . | / [ ] < > \ ` " ;# ( )]   echo 'special character' fi 

though not working properly.

here short working one:

#!/bin/bash echo "enter single character:" read input_source case "$input_source" in [[:lower:]]) echo "lowercase letter" ;; [[:upper:]]) echo "uppercase letter" ;; [0-9] ) echo "digit";; * ) echo "special character";; esac

usage () {   echo usage: $0 char   exit }  [[ $1 ]] || usage  if [[ $1 =~ [[:upper:]] ]]   echo 'uppercase letter' elif [[ $1 =~ [[:lower:]] ]]   echo 'lowercase letter' elif [[ $1 =~ [[:punct:]] ]]   echo 'special character' fi 

regular expression


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -