Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [[ ! -t 0 ]] ; then
- # Input from pipe or file (not terminal)
- export searchfor="$(cat)"
- else
- # Input from terminal (args)
- export searchfor="$1"
- export searchin=.
- if [[ -z $2 ]] ; then
- export searchin=.
- else
- echo "Searching in $2"
- export searchin="$2"
- fi
- fi
- if [[ -z $searchfor ]] ; then
- echo 'Nothing to search for'
- exit 1
- fi
- find $searchin -iname "*$searchfor*"
Add Comment
Please, Sign In to add comment