Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Reverse Find: Recurse upward from CWD to root and list any files matching.
- if [ $# -eq 0 ]; then
- echo "Usage: revfind [-d dir] <filename>"
- exit 1
- fi
- if [ $1 == '-d' ]; then
- shift
- START_WD=`pwd`
- cd $1
- shift
- fi;
- FILENAME="$1"
- while [ true ];
- do
- pwd=`pwd`
- [ -e $FILENAME ] && echo $pwd`[ ! "$pwd" == '/' ] && echo '/'`$FILENAME
- [ "$pwd" == '/' ] && break
- cd ..
- done
- [ -n $START_WD ] && cd "${START_WD}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement