支持多字命令扩展?

时间:2015-12-16 16:47:30

标签: linux bash shell expansion

如何在多字命令上执行大括号扩展?

如果我尝试:

aws s3 ls s3://mybucket/mykey{1..3}/

这会产生:

aws s3 ls s3://mybucket/mykey1/ s3://mybucket/mykey2/     s3://mybucket/mykey3/

但我正在寻找的是:

aws s3 ls s3://mybucket/mykey1/
aws s3 ls s3://mybucket/mykey2/
aws s3 ls s3://mybucket/mykey3/

1 个答案:

答案 0 :(得分:2)

你必须把它包裹在一个循环中:

for i in {1..3}; do aws s3 ls s3://mybucket/mykey$i/; done