Find

From Kb

Revision as of 16:49, 2 April 2014 by Jonathan (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

Look for and change permission of only directories
find . -type d -exec chmod 755 {} \;
find . -type d -exec chmod a+x {} \;


Look for and change permission of only files
find . -type f -exec chmod 644 {} \;
find ./ -name *.pdf -exec chmod 755 {} \;
find . -type d -user fileowner -exec chmod 0755 {} \;
find . -type f -name '*.htm*' -exec chmod 644 {} \;


Move all JPG images to another directory
find . -name "*.jpg" -type f -exec mv {} ../JPGs \;
Remove all SVN directories
find . -name ".svn" -type d -exec rm -rf {} \;


Look for the string "com.apple.itunes" in files that end with ".plist"
sudo find / -name *.plist -exec grep -l 'com.apple.itunes' {} \;
Find files with a wildcard older than 1 day
find /tmp -name "session*" -mtime +1