相关疑难解决方法(0)

如何使用awk或sed进行递归查找/替换字符串?

如何找到并替换每次出现的事件:

subdomainA.example.com
Run Code Online (Sandbox Code Playgroud)

subdomainB.example.com
Run Code Online (Sandbox Code Playgroud)

/home/www/目录树下的每个文本文件递归?

bash awk replace sed

642
推荐指数
20
解决办法
49万
查看次数

为什么找-exec mv {} ./target/ +不起作用?

我想知道到底是什么{} \;{} \+| xargs ...做的.请用解释澄清这些.

以下3个命令运行并输出相同的结果,但第一个命令需要一点时间,格式也略有不同.

find . -type f -exec file {} \;
find . -type f -exec file {} \+
find . -type f | xargs file
Run Code Online (Sandbox Code Playgroud)

这是因为第一个file为来自命令的每个文件运行find命令.所以,基本上它运行如下:

file file1.txt
file file2.txt
Run Code Online (Sandbox Code Playgroud)

但后两个-exec命令运行文件命令一次为所有文件,如下所示:

file file1.txt file2.txt
Run Code Online (Sandbox Code Playgroud)

然后我运行以下命令,第一个运行没有问题,但第二个给出错误消息.

find . -type f -iname '*.cpp' -exec mv {} ./test/ \;
find . -type f -iname '*.cpp' -exec mv {} ./test/ \+ #gives error:find: missing argument to `-exec'
Run Code Online (Sandbox Code Playgroud)

对于命令 …

linux cygwin exec find

96
推荐指数
3
解决办法
16万
查看次数

标签 统计

awk ×1

bash ×1

cygwin ×1

exec ×1

find ×1

linux ×1

replace ×1

sed ×1