Advertisement
Guest User

make_FIND

a guest
Aug 21st, 2011
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.61 KB | None | 0 0
  1. #! /bin/sh
  2. # Build an index of file names, excluding "boring" files
  3. set -e
  4.  
  5. # Explore the directories passed as arguments, or the current directory if called without arguments
  6. if [ $# -eq 0 ]; then
  7.   set .
  8. fi
  9. # Exclude version control bookkeeping files
  10. for x in .git .hg .svn CVS RCS SCCS _darcs; do
  11.   set "$@" -name "$x" -prune -or
  12. done
  13. # Exclude backup files
  14. for x in FIND FIND.old '*~' '.*.swp' '.#*'; do
  15.   set "$@" -name "$x" -or
  16. done
  17.  
  18. # Default output file name if used on a terminal
  19. if [ -t 1 ]; then
  20.   if [ -e FIND ]; then mv FIND FIND.old; fi
  21.   exec >FIND
  22. fi
  23. # Go!
  24. find "$@" -print | sort
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement