logo
🐧 Linux 命令

Find

Find Cheat Sheet - 快速参考指南,收录常用语法、命令与实践。

📂 分类 · Linux 命令🧭 Markdown 速查🏷️ 2 个标签
#find#search
向下滚动查看内容
返回全部 Cheat Sheets

Getting Started

Usage
SHELL
滚动查看更多
$ find [path...] [options] [expression]

Wildcard

SHELL
滚动查看更多
$ find . -name "*.txt"
$ find . -name "2020*.csv"
$ find . -name "json_*"

Option Examples
OptionExampleDescription
-typefind . -type dFind only directories
-namefind . -type f -name "*.txt"Find file by name
-inamefind . -type f -iname "hello"Find file by name (case-insensitive)
-sizefind . -size +1GFind files larger than 1G
-userfind . -type d -user jackFind jack's file
-regexfind /var -regex '.*/tmp/.*[0-9]*.file'Using Regex with find. See regex
-maxdepthfind . -maxdepth 1 -name "a.txt"In the current directory and subdirectories
-mindepthfind / -mindepth 3 -maxdepth 5 -name passBetween sub-directory level 2 and 4

{.show-header}

Type
-type dDirectory
-type fFile
-type lSymbolic link
-type bBuffered block
-type cUnbuffered character
-type pNamed pipe
-type sSocket
Size
-size b512-byte blocks (default)
-size cBytes
-size kKilobytes
-size MMegabytes
-size GGigabytes
-size TTerabytes (only BSD)
-size PPetabytes (only BSD)
Size +/-

Find all bigger than 10MB files

SHELL
滚动查看更多
$ find / -size +10M

Find all smaller than 10MB files

SHELL
滚动查看更多
$ find / -size -10M

Find all files that are exactly 10M

SHELL
滚动查看更多
$ find / -size 10M

Find Size between 100MB and 1GB

SHELL
滚动查看更多
$ find / -size +100M -size -1G

The + and - prefixes signify greater than and less than, as usual.

Names

Find files using name in current directory

SHELL
滚动查看更多
$ find . -name tecmint.txt

Find files under home directory

SHELL
滚动查看更多
$ find /home -name tecmint.txt

Find files using name and ignoring case

SHELL
滚动查看更多
$ find /home -iname tecmint.txt

Find directories using name

SHELL
滚动查看更多
$ find / -type d -name tecmint

Find php files using name

SHELL
滚动查看更多
$ find . -type f -name tecmint.php

Find all php files in directory

SHELL
滚动查看更多
$ find . -type f -name "*.php"
Permissions

Find the files whose permissions are 777.

SHELL
滚动查看更多
$ find . -type f -perm 0777 -print

Find the files without permission 777.

SHELL
滚动查看更多
$ find / -type f ! -perm 777

Find SUID set files.

SHELL
滚动查看更多
$ find / -perm /u=s

Find SGID set files.

SHELL
滚动查看更多
$ find / -perm /g=s

Find Read Only files.

SHELL
滚动查看更多
$ find / -perm /u=r

Find Executable files.

SHELL
滚动查看更多
$ find / -perm /a=x
Owners and Groups

Find single file based on user

SHELL
滚动查看更多
$ find / -user root -name tecmint.txt

Find all files based on user

SHELL
滚动查看更多
$ find /home -user tecmint

Find all files based on group

SHELL
滚动查看更多
$ find /home -group developer

Find particular files of user

SHELL
滚动查看更多
$ find /home -user tecmint -iname "*.txt"
Multiple filenames
SHELL
滚动查看更多
$ find . -type f \( -name "*.sh" -o -name "*.txt" \)

Find files with .sh and .txt extensions

Multiple dirs
SHELL
滚动查看更多
$ find /opt /usr /var -name foo.scala -type f

Find files with multiple dirs

Empty
SHELL
滚动查看更多
$ find . -type d -empty

Delete all empty files in a directory

SHELL
滚动查看更多
$ find . -type f -empty -delete

Find Date and Time

Means
OptionDescription
atimeaccess time (last time file <yel>opened</yel>)
mtimemodified time (last time file <yel>contents was modified</yel>)
ctimechanged time (last time file <yel>inode was changed</yel>)

Example

OptionDescription
-mtime +0Modified greater than 24 hours ago
-mtime 0Modified between now and 1 day ago
-mtime -1Modified less than 1 day ago (same as -mtime 0)
-mtime 1Modified between 24 and 48 hours ago
-mtime +1Modified more than 48 hours ago
-mtime +1wLast modified more than 1 week ago
-atime 0Last accessed between now and 24 hours ago
-atime +0Accessed more than 24 hours ago
-atime 1Accessed between 24 and 48 hours ago
-atime +1Accessed more than 48 hours ago
-atime -1Accessed less than 24 hours ago (same as -atime 0)
-ctime -6h30mFile status changed within the last 6 hours and 30 minutes
Examples

Find last 50 days modified files

SHELL
滚动查看更多
$ find / -mtime 50

find last 50 days accessed files

SHELL
滚动查看更多
$ find / -atime 50

find last 50-100 days modified files

SHELL
滚动查看更多
$ find / -mtime +50 –mtime -100

find changed files in last 1 hour

SHELL
滚动查看更多
$ find / -cmin -60

find modified files in last 1 hour

SHELL
滚动查看更多
$ find / -mmin -60

find accessed files in last 1 hour

SHELL
滚动查看更多
$ find / -amin -60

Find and

Find and delete

Find and remove multiple files

SHELL
滚动查看更多
$ find . -type f -name "*.mp3" -exec rm -f {} \;

Find and remove single file

SHELL
滚动查看更多
$ find . -type f -name "tecmint.txt" -exec rm -f {} \;

Find and delete 100mb files

SHELL
滚动查看更多
$ find / -type f -size +100m -exec rm -f {} \;

Find specific files and delete

SHELL
滚动查看更多
$ find / -type f -name *.mp3 -size +10m -exec rm {} \;
Find and replace

Find all files and modify the content const to let

SHELL
滚动查看更多
$ find ./ -type f -exec sed -i 's/const/let/g' {} \;

Find readable and writable files and modify the content old to new

SHELL
滚动查看更多
$ find ./ -type f -readable -writable -exec sed -i "s/old/new/g" {} \;

See also: sed cheatsheet

Find and rename

Find and suffix (added .bak)

SHELL
滚动查看更多
$ find . -type f -name 'file*' -exec mv {} {}.bak\;

Find and rename extension (.html => .gohtml)

SHELL
滚动查看更多
$ find ./ -depth -name "*.html" -exec sh -c 'mv "$1" "${1%.html}.gohtml"' _ {} \;
Find and move
SHELL
滚动查看更多
$ find . -name '*.mp3' -exec mv {} /tmp/music \;

Find and move it to a specific directory (/tmp/music)

Find and copy
SHELL
滚动查看更多
$ find . -name '*2020*.xml' -exec cp -r "{}" /tmp/backup \;

Find matching files and copy to a specific directory (/tmp/backup)

Find and concatenate

Merge all csv files in the download directory into merged.csv

SHELL
滚动查看更多
$ find download -type f -iname '*.csv' | xargs cat > merged.csv

Merge all sorted csv files in the download directory into merged.csv

SHELL
滚动查看更多
$ find download -type f -iname '*.csv' | sort | xargs cat > merged.csv
Find and sort

Find and sort in ascending

SHELL
滚动查看更多
$ find . -type f | sort

find and sort descending

SHELL
滚动查看更多
$ find . -type f | sort -r
Find and chmod

Find files and set permissions to 644.

SHELL
滚动查看更多
$ find / -type f -perm 0777 -print -exec chmod 644 {} \;

Find directories and set permissions to 755.

SHELL
滚动查看更多
$ find / -type d -perm 777 -print -exec chmod 755 {} \;
Find and compress

Find all .java files and compress it into java.tar

SHELL
滚动查看更多
$ find . -type f -name "*.java" | xargs tar cvf java.tar

Find all .csv files and compress it into cheatsheets.zip

SHELL
滚动查看更多
$ find . -type f -name "*.csv" | xargs zip cheatsheets.zip

相关 Cheat Sheets

1v1免费职业咨询
logo

Follow Us

linkedinfacebooktwitterinstagramweiboyoutubebilibilitiktokxigua

We Accept

/image/layout/pay-paypal.png/image/layout/pay-visa.png/image/layout/pay-master-card.png/image/layout/pay-airwallex.png/image/layout/pay-alipay.png

地址

Level 10b, 144 Edward Street, Brisbane CBD(Headquarter)
Level 2, 171 La Trobe St, Melbourne VIC 3000
四川省成都市武侯区桂溪街道天府大道中段500号D5东方希望天祥广场B座45A13号
Business Hub, 155 Waymouth St, Adelaide SA 5000

Disclaimer

footer-disclaimerfooter-disclaimer

JR Academy acknowledges Traditional Owners of Country throughout Australia and recognises the continuing connection to lands, waters and communities. We pay our respect to Aboriginal and Torres Strait Islander cultures; and to Elders past and present. Aboriginal and Torres Strait Islander peoples should be aware that this website may contain images or names of people who have since passed away.

匠人学院网站上的所有内容,包括课程材料、徽标和匠人学院网站上提供的信息,均受澳大利亚政府知识产权法的保护。严禁未经授权使用、销售、分发、复制或修改。违规行为可能会导致法律诉讼。通过访问我们的网站,您同意尊重我们的知识产权。 JR Academy Pty Ltd 保留所有权利,包括专利、商标和版权。任何侵权行为都将受到法律追究。查看用户协议

© 2017-2025 JR Academy Pty Ltd. All rights reserved.

ABN 26621887572