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.
node?.confIncorrect. ? would match both digits and non-digits.
node[!0-9].confCorrect. node[!0-9].conf selects one non-digit character.
角括弧先頭の!が数字範囲を否定し、数字以外の1文字へ一致する。
node*.confIncorrect. * 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 / 一時ディレクトリ
- Use disposable files and directories for destructive or timestamp-related checks.
- Command details can vary slightly between GNU and non-GNU implementations.
Foundation review
Place the operation
The negated bracket expression excludes digits while still consuming exactly one character.
Check the side effect
Test a digit, a letter, and an underscore to confirm which names are selected.