如果我想打开文件,这里的延续是什么



需要添加什么才能打开找到的所有文件?

查找 . -iname '04*x'

-exec标志用于提供必须对使用 find 命令找到的文件执行的命令。

从手册 -

-exec utility [argument ...] ;
True if the program named utility returns a zero value as its exit status.  Optional arguments may be passed to the utility.  The expression must be terminated by a semicolon (``;'').  If you invoke
find from a shell you may need to quote the semicolon if the shell would otherwise treat it as a control operator.  If the string ``{}'' appears anywhere in the utility name or the arguments it is
replaced by the pathname of the current file.  Utility will be executed from the directory from which find was executed.  Utility and arguments are not subject to the further expansion of shell pat-
terns and constructs.

下面我正在使用vi编辑器打开找到的文件-

find . -iname '04*x' -exec vi {} ;

您可以使用以下命令打开find命令找到的文件:

find . -iname "filename" -exec cat {} ;
find . -iname "filename" | xargs cat

第一个命令是使用-exec,它将输出给cat命令以打开文件并将其显示在终端上。{}表示find命令的输出。

第二个命令是使用xargs,它将输出提供给cat命令打开文件,就像在第一个选项中一样。

最新更新