【问题标题】:Equivalent for find -o (shell) in .cmd等效于 .cmd 中的 find -o (shell)
【发布时间】:2016-01-12 05:20:10
【问题描述】:

有人能告诉我 shell 命令 find -o -samefile 的 .cmd 等效命令吗?

我正在尝试在文件夹中循环以将文件复制到不同的位置。

我原来的shell脚本是: 对于find . -type d -iname qapi_export -o -samefile qapi/common -o -samefile core/api 中的qapi_file;做 cp -p $qapi_file/qapi*.h 包含/qapi/

我试过这样做: FOR /d %%i IN (DIR -i qapi_export qapi\common\ core\api) 做 (xcopy /O %i%\qapi*.h include\qapi)

这并不像我期望的那样工作。如果我使用 for /d ,它会循环一次并且不返回要复制的文件。另一方面,如果我使用 for /r for 循环将变得无止境,我无法打破循环(我尝试为此使用 goto :eof 但它给出了错误 - goto 在这里是意外的)

我对此很陌生,不确定如何进一步进行。我将不胜感激这方面的任何意见

【问题讨论】:

    标签: linux windows shell command-line


    【解决方案1】:

    使用 %%i 而不是 %i% 并使用 /r 遍历所有子目录即可:

    for /r . %%i in (.) do (
      xcopy /y/o %%i\qapi_export\qapi*.h include\qapi
      xcopy /y/o %%i\qapi\common\qapi*.h include\qapi
      xcopy /y/o %%i\core\api\qapi*.h    include\qapi
    ) >nul
    

    【讨论】:

      猜你喜欢
      • 2014-06-08
      • 2020-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-28
      • 2015-05-05
      • 1970-01-01
      相关资源
      最近更新 更多