find ./myFolder -type f -print0 | xargs -0 sed -i ‘s/Application/whatever/g’
请帮助我理解上面的命令.我无法理解命令的这一部分:-print0 | xargs -0,这表示什么?我只知道Unix中的基础知识,因此很难理解这一点.我正在使用bash shell.
还有任何替代命令在Unix中提供相同的功能,从谷歌搜索我得到了与Perl脚本相关的命令,我不知道Perl因此放弃了使用它的想法.
Also are there any alternate commands that provides same functionality in Unix
是的,你可以做到这一切:
find ./myFolder -type f -exec sed -i 's/Application/whatever/g' '{}' \;
find中的-exec选项适用于:
-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 patterns and constructs.