Psychz - Luis
Votes: 0Posted On: Sep 23, 2015 15:07:17
The find command is a very useful tool on all Linux and Unix operating systems that is used to find files or all kinds. I am going to give a brief description of how to use it but I highly recommend reading the find man pages to learn more about this awesome tool.
1. Searching the entire home directory in search for all files that end with the .txt flags modify on the last 5 days
find /home/* -iname "*.txt" -mtime 5 -print
2. Find all files modified less than 24 hours ago
find /home/* -iname "*.txt" -mtime -24 -print
3. Find the files modified 60 min ago
find /home/* -iname "*.txt" -cmin -60 -print
"perm" Flag - You can add the "-perm" flag to search for particular files with whatever permissions you want, 777, 644, 4777, 2777, 7777. For example, You can add the "-perm" flag to search for particular files with whatever permissions you want, 777, 644, 4777, 2777, 7777. Search all files on/with permissions 777 and then run the -exec command to 'ls -l' the dir.
find /* -perm 777 -exec ls -l {} \;
"-exec" command - The -exec can be used to perform shell commands after searching for a file. You can remove the particular file you search, change permissions or tar it.
-exec shell-command-here {} \;
The update command is more simple to use, it is very handy to find all of the same information find command find flags are limited. I recommend reading the man pages, as well running the "updatedb" command to update the locate database before using; otherwise searching won't work for newly installed applications/added files.