Find is an one of the versatile command and very useful to searches files, directory tree hierarchy on Linux and Unix. It's have many options and types for searching files from the directories. The following commands given different outputs,
find [PATH-NAME] [OPTIONS]
1. Last Execute find command:
2. Search Specific directory:
The Below command default will print all files. For example list out from csf directory,
3. Find a specific File :
The below examples to find a file linuxfaq.txt from /home path,
4. Find a file from current directory:
Do you want to specific file from current working directory use this,
5. Find Specific file extension:
The below command displays .php exetension only in /home/thelinuxfaq user directory tree.
6. case-insensitive searching:
7. Set Limit maxdepth of directory traversal:
Find command by default searches entire directory tree recursively, can set limit maxdepth option searching traversal. Assume that, if you dont want to search more than 2 to 3 directory tree down levels, this maxdepth is helpful.
8. Find and print files only:
Find and print the files or images except directories from current working directory like, .txt, .sh, .jpg, etc.
9. Find Specific Directory Name:
10. Find and Print all graphic image files:
./pgrouting/src/common/doc/functions/images/before_node_net.png: PNG image
./pgrouting/src/common/doc/functions/images/after_node_net.png: PNG image
./pgrouting/doc/static/images/ccbysa.png: PNG image
./pgrouting/doc/static/images/pgrouting.png: PNG image
11. Find Empty Files or Directory:
Find all Empty Files,
Find all empty directory,
12. Find a file and remove it.
Part V – Find Files and Directories Based on Size
Find files or Directories by modified times:
Also, possible to searches files or directories based on last modified day, hour, minutes. We can easily to understand by the following commands,
-atime its determine for last accessed time of file.
-ctime its determine for last
Arithmetic operator + sign is used to search for greater than,
Arithmetic oeprator - sign is used to search for less than,
No If there is no sign specified to exact.
13. Days :
The below command find all modified exact 5 days the file from currenty directory
The below command find all modified more than 5 days the file from currenty directory,
The below command find all modified less than 5 days the file from currenty directory
14. Minutes :
15. Find hidden files
16. Find and change permission:
To find and print files with 777 permission,
Find executable permission :
Find files without 755 permission,
Find SFID files:
Find Files with 755 Permissions and Chmod to 0644
Find directories with 755 permission and chmod to 644