Useful linux find command that developer should know
Working with Linux is fun when we can make the best use of Linux commands. Linux find
command is very useful in case of finding things in real quick. But if we can provide the proper parameter to the find command, it becomes tedious to find things on Linux OS.
Following are some really useful find command:
Find a html file that has a keyword
$ find . -type f -name "index.html" -exec grep -il "portfolio" {} \;
Find files that has a size of 100M
$ find / -size 100M
Find files those are greater than 1 GB and older than 6 months
$ find / -mtime +180 -size +1G
Find directory using directory name
$ find / -type d -name "*name-of-the-direcotry*" In Mac, the following command also works along with the above command $ mdfind kind:folder "*name-of-the-directory*"
Find files using file name
$ find / -type f -name "*name-of-the-file*" In Mac, the following command also works along with the above command $ mdfind -name file-name
Find files using file name
$ find / -type f -name "*name-of-the-file*" In Mac, the following command also works along with the above command $ mdfind -name file-name
Find files with full permissions (777)
$ find . -type f -perm 0777 -print
Find files with full permissions (777)
$ find . -type f -perm 0777 -print
Find a specific file and remove it
$ find . -type f -name "doc.txt" -exec rm -f {} \;