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/
Pedro OS
  • 1,383
  • 1
  • 12
  • 15

1 Answers1

3

You'll have to wrap that in a loop:

for i in {1..3}; do aws s3 ls s3://mybucket/mykey$i/; done
janos
  • 115,756
  • 24
  • 210
  • 226