ACE-P-ALE1-04 practice question 4 of 35

In file globbing, which symbol matches any single character?

Full set: 100 questions
Answer options
A: *
B: ? Correct answer
C: []
D: .
Correct Answer:
B. ?
Explanation

In shell pathname expansion, commonly known as file globbing, the question mark (?) is a wildcard character that matches exactly one of any character. For example, the pattern file?.txt would match file1.txt, fileA.txt, and file-.txt, but it would not match file.txt or file10.txt. This functionality is standard across Unix-like shells, including the one used in Arista's Extensible Operating System (EOS).

Why Incorrect

A. \: The asterisk () is a wildcard that matches any string of zero or more characters, not a single character.
C. []: The square brackets ([]) match a single character from a specified set or range of characters, not any single character.
D. .: The period (.) is treated as a literal character in file globbing and is not a wildcard for matching any single character.

References

1. GNU Bash Reference Manual:

Section 3.5.8.1 Pattern Matching: "An asterisk () matches any string of characters, including the null string. A question mark (?) matches any single character."

Source: Free Software Foundation, GNU Bash Reference Manual, Version 5.2.

2. Arista EOS Central Documentation:

Article: Working with Files on an Arista Switch: The documentation demonstrates the use of standard Linux file management commands and wildcards. For instance, in the context of the delete command, it notes, "Wildcards can be used to delete multiple files at once (e.g., delete flash:.log)." This confirms that EOS employs standard shell globbing patterns where ? represents a single character.

Source: Arista EOS Central, "Working with Files on an Arista Switch," Command Line Interface (CLI) section.

3. University Courseware (MIT OpenCourseWare):

The Missing Semester of Your CS Education, Lecture 2: Shell Tools and Scripting: "Globbing lets you use special characters to create patterns that match filenames. ? matches any single character."

Source: MIT OpenCourseWare, "The Missing Semester of Your CS Education," 2020.

Scroll to Top