这就是答案,如果你答对了,恭喜你,你已经掌握了find命令! -prune经常和-path或-wholename一起使用,以避开某个目录,常见的形式是: $ find PATH (-path <don't want this path #1> -o -path <don't want this path #2>) -prune -o -path <global expression for what I do want> 注意:如果同时使用...
因为它可以精确地匹配特定的字符串模式,而不会被一些不相关的字符所干扰。 二、find命令的基本语法 在Linux系统中,可以使用find命令来搜索文件。其基本语法如下: find 目录 -type f -name "pattern" 其中,-type f表示只搜索文件,-name "pattern"表示匹配文件名。pattern是正则表达式的表示方法,具体格式如下: [a...
find / -name "*.log" -exec grep -H "error" {} \; 这里的正则表达式.log表示匹配以 ".log" 结尾的字符串,{}表示我们想要对匹配到的文件执行的操作,grep -H选项用于在输出中高亮包含 "error" 的行。 通过这种方式,我们可以使用正则表达式来精确匹配文件名,从而提高搜索效率。 总的来说,Linux中的find...
find /etc -size +1M -exec ls -lh {} \; {}代表find查找到的内容 find /etc -size +1M -exec cp {} /tmp/test/ \; find / -type -newermt '2018 ' ! -newermt '' find命令按时间查找文件 find /etc -atime 3 #查找/etc目录三天之内查看过的文件 find /etc -mtime -3 #查找/etc目录三...
$ find . -name "[^A-Z][a-z][0-9][0-9].txt" -print ./@y38.txt 注意:此处的模式匹配并不符合正则表达式。 -name对大小写字母敏感,如果想匹配时不考虑大小写可以使用-iname测试项。'i'可以加在许多选项前面,比如-ipath,-iregex,-iwholename等等,都是表示大小写不敏感。
find ./ -regex .*so.*\.gz 查找目录并列出目录下的文件(为找到的每一个目录单独执行ls命令,没有选项-print时文件列表前一行不会显示目录名称) find ./ -type d -print -exec ls {} \; 查找目录并列出目录下的文件(为找到的每一个目录单独执行ls命令,执行命令前需要确认) ...
首先,在你的home目录下面创建下面的空文件,来测试下面的find命令示例。 # vim create_sample_files.shtouch touch mycprogram.c touch MyCProgram.c touch Program.cmkdir backupcd backup touch touch mycprogram.c touch MyCProgram.c touch Program.c
这里,find命令使用-regex参数来匹配以".sh"结尾的文件,sed命令则用于替换文件名中的扩展名。具体而言...
23. 命令 find 查找文件:正则表达式 -regex ; -exec 执行语句的句法 -4 24. 命令 find 查找文件:若干天之前;xargs句法;安全删除的五种方式 -5 25. 命令 find 查找文件:查找后替换实例;查找后压缩实例 -6 26. 命令 find 查找文件:删除查找且保留指定;查找后删除指定代码 -7 ...
Changes the regular expression syntax understood by -regex and -iregex tests which occur later on the command line. Currently-implemented types are emacs (this is the default), posix-awk, posix-basic, posix-egrep and posix-extended. -version, --version Print the find version number and exit...