在搜索文件时,可以使用 -regex 参数指定正则表达式,用于搜索文件中的特定字符串。 例如,要查找包含字符串“example”的文件,可以使用以下 Find 命令: `$ find /var/www -regex ‘.*exmple.*’` 上述命令在“/var/www”目录中查找任何文件,它的文件名包含字符串“example”,然后将其列出来。 也
将结果导出到文件:可以将find命令的结果导出到文件以供后续使用。例如:find /path/to/directory -name "file.txt" > result.txt使用正则表达式匹配:有时你可能需要使用正则表达式来匹配文件名。-regex选项允许你使用正则表达式匹配文件名。例如,查找以数字开头的文件:find /path/to/directory -type f -regex "....
find . -name "*.text" 6. 前后都可使用*号来匹配 find . -path "*local*text" (匹配文件路径或文件) 7. 指定多个文件名匹配 find . \( -name "*.txt" -o -name "*.pdf" \) 或 find . -name "*.txt" -o -name "*.pdf" 8. 基于正则表达式匹配 find . -regex ".*\(\.txt\|\.pd...
– 查找所有包含`example`字符串的文件: “` find . -type f -exec grep -l “example” {} \; “` 注意:上述命令只会显示文件名,不会显示具体匹配的行。 # 4. find命令与正则表达式组合 find命令还可以与正则表达式结合使用来查找文件名。 ## 语法 “` find [path] [options] -regex [pattern] “...
2. 查找指定文件名:可以使用find命令查找指定文件名的文件。例如,要查找当前目录下的名为”example.txt”的文件,可以执行以下命令:find . -name example.txt。其中,”.”表示当前目录。 3. 查找指定文件类型:find命令可以通过-filetype选项查找指定类型的文件。例如,要查找当前目录下的所有文本文件,可以执行以下命令...
[root@localhost ~]# find /root -name "*.txt"[root@localhost ~]# find /root -regex '.*.txt' 10、查找 /home 目录下所有以 a 开头的文件 bash [root@localhost ~]# find /home -name "a*" 11、查找 /home 目录下所有最近7天内修改过的文件 ...
This is the default optimisation level and corresponds to the traditional behaviour. Expressions are reordered so that tests based only on the names of files (for example-nameand-regex) are performed first. 2 Any-typeor-xtypetests are performed after any tests based only on the names of files...
-regex PATTERN:基于正则表达式进行文件名匹配 -user USERNAME: 根据属主查找 -group GROUPNAME: 根据属组查找 -uid UID: 根据UID查找 -gid GID: 根据GID查找 -nouser:查找没有属主的文件 -nogroup: 查找没有属组的文件 -type f: 普通文件 d c
1、find 文件查找 查找txt和pdf文件 find . ( -name "*.txt" -o -name "*.pdf" ) -print 正则方式查找.txt和pdf find . -regex ".*(.txt|.pdf)$" #-iregex:忽略大小写的正则 否定参数:查找所有非txt文本 find . ! -name "*.txt" -print ...
-iregex ".*\(\.txt\|\.log\)$" find 否定参数用法举例 #找出/mingongge下不是以.log结尾的文件 [root@centos7 ~]# find /mingongge ! -name "*.log" 基于目录深度搜索 #向下最大深度限制为5 [root@centos7 ~]# find . -maxdepth 5 -type f #搜索出深度距离当前目录至少3个子目录的所有...