Replacing in Found Files
Replace one string by another in all file found by find.
find . -name *whatyouwant* -exec perl -pi.bak -e 's/TEXT_TO_REPLACE/TEXT_TO_REPLACE_IT_WITH/g' {} \;
Replace one string by another in all file found by find.
find . -name *whatyouwant* -exec perl -pi.bak -e 's/TEXT_TO_REPLACE/TEXT_TO_REPLACE_IT_WITH/g' {} \;
Use this command to find all the links in the current directory…
find . -lname "*"
You can use locate to find files with name that matches a said regexp…
locate -i -r '\.jpg$'
Use this command to find files of a given mime-type. In this example, we are looking for video files…
find -type f -print0 | xargs -0 file -i | grep -i video
And, by the way, this command, and the last two commands were sponsored by Mahesh. Happy now?
Find the version of alsa using this command…
cat /proc/asound/version
Thanks to Sreenath(Hacking With Debian) for this tip.
Grep that searches recursively, ignores binary files, and doesn’t look inside Subversion hidden folders.
grep -Ir --exclude="*\.svn*" "pattern" *
Find all files with ‘.log’ extention and make an bzip archive
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2
This command removes the SVN data from a folder.
find -name .svn -exec rm -rf {} \;
Search files with ‘.rpm’ extension ignoring removable partitions as cdrom, pen-drive, etc.
find / -xdev -name \*.rpm
Search files created or changed within 10 days
find /usr/bin -type f -mtime -10