且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Windows cmd 将一个命令的输出作为参数传递给另一个

更新时间:2023-02-14 16:24:30

cmd 中没有 $ 操作符.
重定向运算符(>>>>)需要文件或流句柄.
管道 | 将命令的标准输出传递到另一个命令的标准输入.

There is no $ operator in cmd.
Redirection operators (<, >, >>) expect files or stream handles.
A pipe | passes the standard output of a command into the standard input of another one.

A for/F 循环 但是能够捕获命令的输出并将其提供在变量引用中(在示例中为 %A);看下面的代码:

A for /F loop however is capable of capturing the output of a command and providing it in a variable reference (%A in the example); see the following code:

for /F "usebackq delims=" %A in (`git status -s -b ^| sed -n '2p' ^| cut -d' ' -f2-`) do git diff %A