nerdexam
CompTIA

XK0-005 · Question #218

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…

The correct answer is A. touch {2015,2016,2017,2018}.{q1,q2,q3,q4}. To quickly create multiple empty files following a specific naming pattern for years and quarters, Linux brace expansion should be used.

System Management

Question

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?

Options

  • Atouch {2015,2016,2017,2018}.{q1,q2,q3,q4}
  • Btouch [2015,2016,2017,2018].[q1,q2,q3,q4]
  • Ctouch 2015,2016,2017,2018.q1,q2,q3,q4
  • Dtouch {2015.2016.2017.2018}.{q1.q2.q3.q4}

How the community answered

(21 responses)
  • A
    95% (20)
  • B
    5% (1)

Why each option

To quickly create multiple empty files following a specific naming pattern for years and quarters, Linux brace expansion should be used.

Atouch {2015,2016,2017,2018}.{q1,q2,q3,q4}Correct

The `touch` command combined with brace expansion `{{2015,2016,2017,2018}}.{{q1,q2,q3,q4}}` generates all combinations of years and quarters, creating 16 distinct filenames like `2015.q1`, `2015.q2`, etc. This allows for the efficient creation of all required empty files with a single command.

Btouch [2015,2016,2017,2018].[q1,q2,q3,q4]

Square brackets `[]` are used for character ranges or sets in shell globbing, not for generating a Cartesian product of strings for file creation as required here.

Ctouch `2015,2016,2017,2018`.`q1,q2,q3,q4`

Backticks `` ` `` are used for command substitution, executing an enclosed command and replacing it with its output, which is not applicable for generating multiple filenames.

Dtouch {2015.2016.2017.2018}.{q1.q2.q3.q4}

While double braces indicate brace expansion, using dots `.` instead of commas `,` within the braces `{{2015.2016...}}` does not create separate elements for expansion; it treats the entire string as a single literal part or forms an invalid pattern.

Concept tested: Linux shell brace expansion for file creation

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Brace-Expansion

Topics

#touch command#brace expansion#file management#shell basics

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice