SHARE
TWEET

Untitled

a guest Jun 19th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. dflag=
  4. iflag=
  5. oflag=
  6. while getopts 'dio:' OPTION
  7. do
  8.   case $OPTION in
  9.     d)  dflag=1
  10.         ;;
  11.     i)  iflag=1
  12.         ;;
  13.     o)  oflag=1
  14.         oval="$OPTARG"
  15.         if [ ! -d "$oval" ]; then
  16.           printf 'Option -o "%s" is not a directory\n' "$oval"
  17.           exit 2
  18.         fi
  19.         ;;
  20.     ?)  printf "Usage: %s [-d] [-i] [-o /path/to/output]\n" $0 >&2
  21.         exit 2
  22.         ;;
  23.   esac
  24. done
  25.  
  26. if [ "$dflag" ]; then
  27.   printf "Option -d specified\n"
  28. fi
  29. if [ "$iflag" ]; then
  30.   printf "Option -i specified\n"
  31. fi
  32. if [ "$oflag" ]; then
  33.   printf 'Option -o "%s" specified\n' "$oval"
  34. fi
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top