Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use find command in linux system

Shulou Source: shulou.com Published: 2022-06-01 17:30:26 09月13日 Update

Linux system how to use find commands, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Find the file MyCProgram.c in the current directory and subdirectory

# find. -name "MyCProgram.c"

Find files and ignore case

# find. -iname "MyCProgram.c"

Find files that do not contain MyCProgram.c

Find. -maxdepth 1-not-iname "MyCProgram.c"

Look for passwd in / subdirectories at levels 3 to 5 below

# find /-mindepth 3-maxdepth 5-name passwd

Find and execute commands

Find. -iname "MyCProgram.c"-exec md5sum {}\

Find files greater than 100m

# find ~-size + 100m

Find files less than 100m

# find ~-size-100m

Find files equal to 100m

# find ~-size 100m

Find the largest 5 files in directories and subdirectories

Find. -type f-exec ls-s {}\; | sort-n-r | head-5

Find the smallest 5 files in directories and subdirectories

# find. -type f-exec ls-s {}\; | sort-n | head-5

Find 5 files with non-zero and smallest size

# find. -not-empty-type f-exec ls-s {}\; | sort-n | head-5

Find files where all users have write permissions

# find. -perm-Grouw-type f-exec ls-l {}\

Find files in the / logs directory that were changed before 5 days and delete them

$find logs-type f-mtime + 5-exec rm {}\

Look for ordinary files in the / var/logs directory that were changed before 7 days and ask them before deleting them

$find / var/logs-type f-mtime + 7-ok rm {}\

You can use some kind of filename pattern to match files. Remember to enclose the filename pattern in quotation marks, otherwise the matching expansion will lead to confusion of find parameters.

$find. -name [Amurz] *-print

Find files with a file permission bit of 755 in the current directory, that is, files that can be read, written and executed by the file owner, and that can be read and executed by other users.

$find. -perm 755-print

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Files directories subdirectories subdirectories commands minimum file name time permissions mode user help system normal maximum clear clutter content parameters size Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Huawei MariaDB Docker Shulou Information