Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Reverse Find: Recurse upward from CWD to root and list any files matching.
  4.  
  5. if [ $# -eq 0 ]; then
  6. echo "Usage: revfind [-d dir] <filename>"
  7. exit 1
  8. fi
  9.  
  10. if [ $1 == '-d' ]; then
  11. shift
  12. START_WD=`pwd`
  13. cd $1
  14. shift
  15. fi;
  16.  
  17. FILENAME="$1"
  18. while [ true ];
  19. do
  20. pwd=`pwd`
  21. [ -e $FILENAME ] && echo $pwd`[ ! "$pwd" == '/' ] && echo '/'`$FILENAME
  22. [ "$pwd" == '/' ] && break
  23. cd ..
  24. done
  25.  
  26. [ -n $START_WD ] && cd "${START_WD}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement