linux-shell (6) -Bash wildcard and other special symbols

1: wildcard (match file name)

Wildcard effect
? Matches an arbitrary character
* Match 0 or any number of any characters, that is, can match any content
[] Match any character in the brackets. For example: [abc] means it must match a character, either a, or b, or c
[-] Match any character in the brackets,-represents a range. For example: [az] means to match a lower case letter.
[^] Logical not, it means that the match is not a character in square brackets, for example: [^ 0-9] means match a character that is not a number.

Example: Delete files in temporary folder

ls * abc means that only abc can be added after any character

ls? abc indicates that abc must be preceded by only one character

2: Other special characters in Bash:

symbol effect
' ' apostrophe. All special symbols in single quotes, such as '$' and '`' (back quotes) have no special meaning.
" " Double quotes. Special symbols have no special meaning in double quotes, but "$" and "` "and" \ "are the exceptions, with the special meanings of" call variable value "," quote command "and" escape character "
`` (Above the table key) Backticks. The content enclosed in backticks is a system command, which will be executed first in Bash. Same as $ (), but it is recommended to use $ (), because backticks are very easy to misread.
$() Used to quote system commands
# In the Shell script, the line beginning with # represents a comment
$ Used to call the value of the variable, if you need to call the value of the variable name, you need to get the value of the variable by way of $ name
\ Escape characters, special symbols following \ will lose their special meaning and become ordinary characters. Such as \ $ will output the "$" symbol instead of being used as a variable reference

Use Cases:

Published 158 original articles · Like 10 · Visitors 20,000+

Guess you like

Origin blog.csdn.net/ab1605014317/article/details/105616092