Guest User

Untitled

a guest
Oct 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/bin/sh
  2. DEFAULT_FILES="html erb slim haml css scss sass js coffee rb rake yml"
  3.  
  4. usage_msg() {
  5. echo "usage: `basename $0` grep_text [find_files]"
  6. echo "(example) `basename $0` current_user erb slim"
  7. }
  8.  
  9. ### error check & init
  10. case $# in
  11. 0 ) # param none
  12. usage_msg
  13. exit 1
  14. ;;
  15. 1 ) # set default params
  16. set -- ${1} ${DEFAULT_FILES}
  17. ;;
  18. * )
  19. ;;
  20. esac
  21.  
  22. ### build params
  23. TARGET_TEXT=$1
  24. extensions="-type f -name *.${2}"
  25. shift
  26. while [ "$2" != "" ]; do
  27. extensions="${extensions} -o -type f -name *.${2}"
  28. shift
  29. done
  30.  
  31. ### execute
  32. find . ${extensions} | xargs egrep -n --color=always ${TARGET_TEXT}
  33. exit 0
Add Comment
Please, Sign In to add comment