1

How do I perform brace expansion on a multi-word command?

If I try:

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

This produces:

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

But what I'm looking for is:

aws s3 ls s3://mybucket/mykey1/
aws s3 ls s3://mybucket/mykey2/
aws s3 ls s3://mybucket/mykey3/
user182917
  • 1,688
  • 2
  • 14
  • 17

1 Answers1

4

You'll have to wrap that in a loop:

for i in {1..3}; do aws s3 ls s3://mybucket/mykey$i/; done
janos
  • 120,954
  • 29
  • 226
  • 236