bash – 将多行STDIN输入提供给命令

我有一个输出git repository SSH URL的脚本,如下所示:
[email protected]:namespace/project.git
[email protected]:another_namespace/some_other_project.git

我想为每一行运行命令git clone(或其他命令).

我尝试将它连接到xargs,但我要么输出一行,要么多行输入转储到单个命令.

如何通过管道在每一行上运行任意命令?

事实证明,你可以在bash中使用while循环(改编自 this answer):
<whatever your command/output is> | while read line; do echo $line; done

其中echo是您的命令,并使用$line作为每行的输出,您可以根据需要进行调整.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...