The directory contains node1.conf, nodeA.conf, and node_.conf.
Select names whose character after node is one non-digit.
Which Bash pattern is appropriate?
In a Bash glob, [!0-9] matches one character that is not a digit. The negation marker is first inside the brackets.
Detailed explanation
node[0-9].confIncorrect. [0-9] matches digits.
Incorrect. [0-9] matches digits.
node?.confIncorrect. ? would match both digits and non-digits.
Incorrect. ? would match both digits and non-digits.
node[!0-9].confCorrect. node[!0-9].conf selects one non-digit character.
Correct. node[!0-9].conf selects one non-digit character.
node*.confIncorrect. * allows zero or more characters and is too broad.
Incorrect. * allows zero or more characters and is too broad.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); touch "$tmp/node1.conf" "$tmp/nodeA.conf" "$tmp/node_.conf"; (cd "$tmp" && printf '%s\n' node[!0-9].conf); rm -rf "$tmp"Expected result
nodeA.conf
node_.confKey points
- [!... ] is a negated set
- Brackets match one character
- ? does not restrict the character type
Notes
- Environment: Bash 5.x / 一時ディレクトリ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.