類似した名前のリポジトリをクローンする

類似した名前のリポジトリをクローンする

次のようなことをしたいです:

git clone https://github.com/meteor{A,B,C,D}test

{}しかし、bash は をeach に変換しません。何が間違っているのでしょうか?

答え1

使用している構文は{A,B,C,D}有効ですが、引数が分割されます。つまり、コマンドは次のように実行されます。

git clone https://github.com/meteorAtest https://github.com/meteorBtest https://github.com/meteorCtest https://github.com/meteorDtest

必要なのは、4 つの異なるコマンドを実行することです。これを行う簡単な方法の 1 つはforループです。

for url in https://github.com/meteor{A,B,C,D}test; do git clone "$url"; done

答え2

これもできます

echo https://github.com/meteor{A,B,C,D}test | xargs -n 1 -d ' ' git clone

echoはそれを4つのgit URLに展開し、git cloneクローンします。

関連情報