code_junkie

Fast recursive grepping of svn working copy

Nov 11th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. svn ls -R | xargs -d 'n' grep <string-to-search-for>
  2.  
  3. s () {
  4. local PATTERN=$1
  5. local COLOR=$2
  6. shift; shift;
  7. local MOREFLAGS=$*
  8.  
  9. if ! test -n "$COLOR" ; then
  10. # is stdout connected to terminal?
  11. if test -t 1; then
  12. COLOR=always
  13. else
  14. COLOR=none
  15. fi
  16. fi
  17.  
  18. find -L .
  19. -not ( -name .svn -a -prune )
  20. -not ( -name templates_c -a -prune )
  21. -not ( -name log -a -prune )
  22. -not ( -name logs -a -prune )
  23. -type f
  24. -not -name *.swp
  25. -not -name *.swo
  26. -not -name *.obj
  27. -not -name *.map
  28. -not -name access.log
  29. -not -name *.gif
  30. -not -name *.jpg
  31. -not -name *.png
  32. -not -name *.sql
  33. -not -name *.js
  34. -exec grep -iIHn -E --color=${COLOR} ${MOREFLAGS} -e "${PATTERN}" {} ;
  35. }
  36.  
  37. # s foo | less
  38. sl () {
  39. local PATTERN=$*
  40. s "$PATTERN" always | less
  41. }
  42.  
  43. # like s but only lists the files that match
  44. smatch () {
  45. local PATTERN=$1
  46. s $PATTERN always -l
  47. }
  48.  
  49. # recursive search (filenames) - find file
  50. f () {
  51. find -L . -not ( -name .svn -a -prune ) ( -type f -or -type d ) -name "$1"
  52. }
Add Comment
Please, Sign In to add comment