Open today from 11 AM to 11:55 PM. Go to the class moodle to take the quiz.
bash
) and/or other tools processes those characters and give them their special meaningMetacharacter | Name | Meaning |
---|---|---|
* | asterisk | matches zero or more characters |
? | question mark | matches a single character |
[abc] | square brackets | matches ONE character in the set a, b, or c |
[!abc] | square brackets | matches ONE character NOT in the set a, b, or c |
[a-z] | square brackets | matches ONE character in the range a-z |
[!a-z] | square brackets | matches ONE character NOT in the range a-z |
{ab,cd,de} | curly braces | matches among a set of substrings |
\ | backslash | interpret the next character literally |
any other character | matches itself, e.g. an “a” character will match an “a” in the target string |
In lab 1, you encountered the following wildcard expression
case $1 in
*[!0-9]*) echo "Error: test-exit requires an integer argument."
exit 2
;;
"") echo "Error: test-exit requires a non-empty argument."
exit 3
;;
*) ;;
esac
Metacharacter | Name | Meaning | Wildcard Meaning |
---|---|---|---|
. | period | match a single instance of any character except newline | question mark (?) had this meaning in wildcards, with the exception that wildcards don't generally worry about newlines |
[abc] | square brackets | matches ONE character in the set a, b, or c | ditto |
[^abc] | square brackets | matches ONE character NOT in the set a, b, or c | ditto, however syntax for bash is [!abc] |
[a-z] | square brackets | matches ONE character in the range a-z | ditto |
[^a-z] | square brackets | matches ONE character NOT in the range a-z | ditto, however syntax for bash is [!abc] |
pattern* | asterisk | matches zero or more instances of the previous pattern | matches zero or more characters |
pattern+ | plus sign | matches one or more instances of the previous pattern | no special meaning |
pattern? | question mark | matches zero or one instance of the previous pattern | matches a single character |
pattern1 | pattern2 | pipe | matches pattern1 or pattern2 | brace expansion is closest match (definitely NOT an exact match) |
(pattern1pattern2...) | parens | combines one or more patterns in a logical group; also captures the characters that match the included patterns during a match for special processing | no corresponding construct |
^pattern | hat | matches subsequent pattern at the beginning of a line | no special meaning |
pattern$ | dollar sign | matches previous pattern at the end of a line | no special meaning |
\ | backslash | interpret the next character literally | interpret the next character literally |
any other character | matches itself, e.g. an “a” character will match an “a” in the target string | ditto |