Guest User

Untitled

a guest
Mar 24th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [[ ! -t 0 ]] ; then
  4.  
  5. # Input from pipe or file (not terminal)
  6. export searchfor="$(cat)"
  7.  
  8. else
  9. # Input from terminal (args)
  10.  
  11. export searchfor="$1"
  12. export searchin=.
  13.  
  14. if [[ -z $2 ]] ; then
  15. export searchin=.
  16. else
  17. echo "Searching in $2"
  18. export searchin="$2"
  19. fi
  20. fi
  21.  
  22. if [[ -z $searchfor ]] ; then
  23. echo 'Nothing to search for'
  24. exit 1
  25. fi
  26.  
  27. find $searchin -iname "*$searchfor*"
Add Comment
Please, Sign In to add comment