CompTIA Linux+ (XK0-004) — Question 42
A junior Linux administrator needs to create 16 empty files quickly that will contain sales information for each quarter for the past four years. Which of the following commands will meet this requirement?
Answer options
- A. touch {2015,2016,2017,2018}.{q1,q2,q3,q4}
- B. touch [2015,2016,2017,2018].[q1,q2,q3,q4]
- C. touch '2015,2016,2017,2018'.'q1,q2,q3,q4'
- D. touch {2015.2016.2017.2018}.{q1.q2.q3.q4}
Correct answer: A
Explanation
The command in option A is correct because it uses brace expansion to create multiple files efficiently. Options B and D incorrectly use brackets and periods instead of commas and braces, which will not yield the desired output. Option C incorrectly uses single quotes, which prevents the brace expansion from functioning properly.