Linux uses the find command to find files

Time:2021-8-5
#Find the file in the directory according to the file name
find /path -name keyword

#Find the file in the directory according to the file name(忽略大小写)
find /path -iname keyword

#Fuzzy search for files in the directory according to the file name
find /etc -name "*.conf"


#Find the files in the directory according to the file type (block device)
find /dev -type b

#Find the files in the directory according to the file type (character device)
find /dev -type c

#Find the files in the directory according to the file type (soft connection file)
find /usr/bin/ -type l


#Find the file in the directory according to the file size. The negative sign is [0, size-1]
find /etc/ -type f -size -1M

#Find the file in the directory according to the file size. The unsigned is (size-1, size]
find /etc/ -type f -size 1M

#Find the file in the directory according to the file size. The plus sign is (size, positive infinity]
find /etc/ -type f -size +1M


#Find files in the directory according to users and groups
find . -user wu -group wu -type f


#Find files in the directory according to permissions
find . -type f -perm 644


#Two days ago, assuming that the current date is 22, it is before 20 (excluding 20)
find . -type f -mtime +2

#Within two days, if the current date is 22, it will be after 20 (excluding 20)
find . -type f -mtime +2

#Two days on the same day, assuming that the current day is the 22nd, it will be the 20th
find . -type f -mtime 2

#Two days on the same day, assuming that the current day is the 22nd, it will be the 20th,以0点为界,而不是24小时为界,-daystart需写在对应的属性之前
find . -type f -daystart -mtime 2


#Additional commands, - LS display details
find /path -name keyword -ls

#Attach command, - delete find and delete
find /path -name keyword -delete

#Additional command, - exec | - OK command finds and executes the command. 1. It must end with (space + backslash + semicolon), and 2. {} represents the found file
find /path -name keyword -ok cp {} /tmp \;

#- print is the default option
find /path -name keyword -print