Bird
0
0

You want to write a script that lists all S3 buckets and saves their names to a file named 'buckets.txt'. Which AWS CLI command should you use?

hard📝 Application Q8 of 15
AWS - CLI
You want to write a script that lists all S3 buckets and saves their names to a file named 'buckets.txt'. Which AWS CLI command should you use?
Aaws s3api list-buckets > buckets.txt
Baws s3 ls > buckets.txt
Caws s3api list-buckets --query 'Buckets[].Name' --output text > buckets.txt
Daws s3api list-buckets --names > buckets.txt
Step-by-Step Solution
Solution:
  1. Step 1: Identify command to list bucket names only

    'aws s3api list-buckets' lists buckets; using --query 'Buckets[].Name' extracts only names.
  2. Step 2: Confirm output redirection and format

    --output text formats output as plain text, suitable for saving. Redirecting with '> buckets.txt' saves to file.
  3. Final Answer:

    aws s3api list-buckets --query 'Buckets[].Name' --output text > buckets.txt -> Option C
  4. Quick Check:

    Use --query and --output text to save bucket names [OK]
Quick Trick: Use --query and --output text to extract and save data [OK]
Common Mistakes:
  • Not using --query to filter names
  • Using incorrect flags like --names
  • Saving full JSON output without filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes