1. 在当前目录及子目录中,查找大写字母开头的txt文件
指令: $ find . -name '[A-Z]*.txt' -print
2.在/etc及其子目录中,查找host开头的文件
指令: $ find /etc -name 'host*' -print
3.在$HOME目录及其子目录中,查找所有文件
指令: $ find ~ -name '*' -print
4. 在当前目录及子目录中,查找不是out开头的txt文件
指令: $ find . -name "out*" -prune -o -name "*.txt" -print
5.忽略文件名大小写查找a.txt
指令: find . /tmp -iname 'a.txt' -print
6.在当前目录除aa之外的子目录内搜索 txt文件
$ find . -path "./aa" -prune -o -name "*.txt" -print
7.在当前目录及子目录下,查找符号链接文件
指令: $ find . -type l -print
8.查找2天内被更改过的文件
指令: $ find . -mtime -2 -type f -print
9. 查找2天前被更改过的文件
$ find . -mtime +2 -type f -print
10. 查找超过1M的文件
指令: $ find / -size +1M -type f -print
11.查找文件中包含字符串的所有行,并存储
指令: grep re /usr/share/rhel/secrets/redhat.repo > /root/files
本文详细介绍了在不同目录和条件下进行文件搜索的方法,包括大小写不敏感搜索、特定文件类型过滤、修改时间判断、文件大小筛选,以及使用正则表达式查找特定行等内容,是IT技术人员必备的实用指南。
17万+

被折叠的 条评论
为什么被折叠?



