需要添加什么才能打开找到的所有文件?
查找。-iname '04*x‘
发布于 2019-09-23 11:49:37
-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 {} \;发布于 2019-09-23 11:33:29
您可以使用以下命令打开通过find命令找到的文件:
find . -iname "filename" -exec cat {} \;
find . -iname "filename" | xargs cat第一个命令是使用-exec,它将向cat命令提供输出,以打开文件并在终端上显示它。{}表示find命令的输出。
第二个命令是使用xargs,它将提供outout to cat命令来打开文件,就像在第一个选项中一样。
https://stackoverflow.com/questions/58055119
复制相似问题