将多行STDINinput送入命令

我有一个脚本,输出git存储库的SSHurl,如下所示:

[email protected]:namespace/project.git [email protected]:another_namespace/some_other_project.git 

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

我试着将它输送到xargs ,但是我要么在一行中获得输出,要么将多行input转储为单个命令。

你如何通过pipe道在每一行上运行一个任意的命令?

原来,你可以在bash中使用一个while循环来做到这一点(从这个答案改编):

 <whatever your command/output is> | while read line; do echo $line; done 

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