linux中的Find命令
以下是什么意思linux中的Find命令,linux,ubuntu,find,Linux,Ubuntu,Find,以下是什么意思 find myDirectory -name myFile -exec ls \-ln {} \; 我看了,但不太明白 -exec command True if the executed command returns a zero value as exit status. The end of command must be punctuated by an escaped semicolon. A command argument {} is replaced b
find myDirectory -name myFile -exec ls \-ln {} \;
我看了,但不太明白
-exec command True if the executed command returns a zero value as exit status. The end of command must be punctuated by an escaped semicolon. A command argument {} is replaced by the current path name.
本部分-exec ls \-ln{}代码>我不清楚
问候
find myDirectory -name myFile -exec ls \-ln {} \;
它说在目录myDirectory
中查找myFile
,一旦找到所有文件,然后执行文件列表命令,即在linixls
中,对找到的文件使用命令选项-l
和-n
因此,最终您将获得所有myFiles
以及ls
命令结果。这意味着:在当前目录及其所有子目录中查找所有名为myFile
的文件,并为找到的每个文件运行ls-ln
例如:
$ mkdir a
$ touch myFile a/myFile
$ find -name myFile -exec ls -ln {} \;
-rw-r--r-- 1 1000 1000 0 Jun 17 13:07 ./myFile
-rw-r--r-- 1 1000 1000 0 Jun 17 13:07 ./a/myFile
在这种情况下,find
将运行ls
两次:
ls -ln ./myFile
ls -ln ./a/myFile
每次它都会将{}
展开为找到的文件的全名
我还必须补充一点,在这种情况下,您需要在-ln之前使用反斜杠。是的,您可以使用它,但它在这里绝对没有用。离题。但请尝试适当的手册页:例如。甚至Wikipedia:.exec对找到的每个文件执行命令,而不是对group@fvu,这只是一个解释。。。我的意思是一样的。只是指出解释可能会导致误解-你的编辑让它更清楚,+1