
我想做這樣的事情:
git clone https://github.com/meteor{A,B,C,D}test
但 bash 不會將 the 轉換{}
為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 個不同的指令。執行此操作的簡單方法是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
克隆它