SHARE
TWEET

Untitled

a guest Oct 13th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. ALL=false
  4. PATH=./
  5.  
  6. usage()
  7. {
  8.   echo "Usage: $0 WORD [-a] [ -p PATH ]"
  9.   exit 2
  10. }
  11.  
  12. if [ $# = 0 ]
  13. then
  14.   usage
  15. fi
  16.  
  17. WORD=$1
  18. shift
  19.  
  20. while getopts 'ap:' OPTION
  21. do
  22.   case ${OPTION} in
  23.   a)
  24.     ALL=true ;;
  25.   p)
  26.     PATH=$OPTARG ;;
  27.   esac
  28. done
  29.  
  30. if [ "$ALL" = true ]
  31. then
  32.   RESULT=$(/bin/grep -lR ${WORD} $PATH)
  33. else
  34.   RESULT=$(/bin/grep -lR --include \*.txt --include \*.sh ${WORD} $PATH)
  35. fi
  36.  
  37. echo "$RESULT"
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