[英]How to filter batch file with pipe?
I am trying to filter (git staged) files and concatenate it.我正在尝试过滤(git staged)文件并将其连接起来。 I am getting error as file not found.
由于找不到文件,我收到错误消息。 refer
参考
set List='git diff --cached --name-only --diff-filter=ACMR'
set output=
for /f "delims=" %%a in (%List%) do (
(Echo "%%a"| find ".java" set output=!output! "%%a") || (
REM set output=!output! "%%a"
))
echo %output%
Thanks in advance!提前致谢!
@Set "ListCommand='git diff --cached --name-only --diff-filter^=ACMR ^^^| "%%__AppDir__%%findstr.exe" /L /I /E ".java"'" @Set "output=" @For /F Delims^= %%G In (%ListCommand%)Do @If Not Defined output (Set output="%%~G")Else Set "output=!output! "%%~G"" @Echo %output%
This assumes that you have delayed expansion enabled, and that none of your returned file names contain exclamation marks.这假定您已启用延迟扩展,并且您返回的文件名都不包含感叹号。 It also assumes that you do not have too many returned filenames, otherwise the size of the environment could be exceeded.
它还假设您没有太多返回的文件名,否则可能会超出环境的大小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.