I need to keep a record of some Linux/cygwin "find" commands that I find useful. This is sort of a cookbook or quick reference of find commands that are handy to have around.
Print files which were modified within the last 10 days but and NOT in a "CVS", "build" or "classes" folder:
find . -type d -name CVS -prune -o -name build -prune -o -name classes -prune -o -mtime -10 \! -type d -print
Print a sorted list of the largest files above 20000k minimum size
find . -type f -size +20000k -printf '%kk %p\n' | sort -n -r
Print files with XML extensions containing the phrase "search string"
find . -type f -name "*.xml" -exec grep "search string" '{}' /dev/null \; -print
Copy files newer than file X
Where file-x.txt is the file, and /tmp/copy-destination/ is the place you want to copy the files to:
find . -newer file-x.txt $1 | xargs -I {} cp -p $1{} /tmp/copy-destination/
No comments:
Post a Comment