SHARE
TWEET

get number of latin letter in alphabet use printf

tolikpunkoff Jun 4th, 2019 50 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=0
  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. S_CODE=`printf '%d' \'$SFND`
  14. A_CODE=`printf '%d' \'a`
  15. SNUM=$( expr $S_CODE - $A_CODE + 1 )
  16. echo "$SFND is $SNUM"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top