Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
linux中的Find命令_Linux_Ubuntu_Find - Fatal编程技术网

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
,一旦找到所有文件,然后执行文件列表命令,即在linix
ls
中,对找到的文件使用命令选项
-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