home *** CD-ROM | disk | FTP | other *** search
/ The UNIX CD Bookshelf / OREILLY_TUCB_UNIX_CD.iso / upt / examples / LINUX / ARCHIVE / ASCII.Z / ASCII / sbin / ascii
Encoding:
Text File  |  1993-01-01  |  566 b   |  21 lines

  1. #!/bin/sh
  2. #
  3. # ascii - search for the octal value of a character.
  4.  
  5. # $file is a file containing an ASCII character chart with the octal and
  6. # hexadecimal value of each ASCII character.
  7. file=/usr/pub/ascii
  8.  
  9. # Make pattern with spaces to match field in $file exactly:
  10. case "$1" in
  11. ?)    pat=" $1 " ;;
  12. ??)    pat="$1 " ;;
  13. ???)    pat="$1" ;;
  14. *)    echo "Usage: `basename $0` char
  15.     (char must be single character like 'a' or name like 'soh')." 1>&2
  16.     ;;
  17. esac
  18.  
  19. # Search for the octal representation of character(s) specified
  20. sed -n "1,/^\$/s/.*|\([0-9][0-9][0-9]\) $pat|.*/\1/p" $file
  21.