查找并执行:为什么这个命令不起作用?

查找并执行:为什么这个命令不起作用?

我不明白为什么 echo 打印空行(最新的 cygwin 版本):

~/tmp >find mydor/ -name "*php"
mydor/es/c/packags.php
mydor/etns/inx.php
mydor/pacepors.php
mydor/XAE.php

~/tmp >find mydor/ -name "*php" -exec echo {} \;
~/tmp >find mydor/ -name "*php" -exec echo "{}" \;
~/tmp >find mydor/ -name "*php" -exec echo '{}' \;

~/tmp >

~/tmp >find --version
find (GNU findutils) 4.5.11
Packaged by Cygwin (4.5.11-1)
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)

答案1

我确实找到了答案。这是我让它工作的方法(并且只有第一个成功时才可以连续执行 2 个进程,这是我在谷歌中找不到的解决方案):

find ./ -name "*php" -exec sh -c "sed 's/ \+ /\t/g' \"{}\" > tmpfile && mv tmpfile \"{}\"" \;

相关内容