Advertisement
tolikpunkoff

get number of latin letter in alphabet

Jun 3rd, 2019
379
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. #get number of latin letter in alphabet
  4. #use nlett <letter>, e.g nlett a
  5.  
  6. SNUM=1
  7. SFND=`echo $1|grep '^[a-z]$'`
  8. if [ -z "$SFND" ]; then
  9.     echo "Error: in first parameter must be one small latin letter!"
  10.     exit 1
  11. fi
  12.  
  13. for SYMB in {a..z}; do
  14.     if [[ "$SYMB" == "$SFND" ]]; then
  15.     break
  16.     else
  17.     let "SNUM=SNUM+1"
  18.     fi
  19. done
  20.  
  21. echo "$SFND is $SNUM"
Advertisement
RAW Paste Data Copied
Advertisement