command-line wildcard characters
command-line wildcard characters:
An example:
[Email protected] ~]# LS/DEV/SDA
/dev/sda
[Email protected] ~]# ls/dev/sda1
/dev/sda1
[email protected] ~]# ls/dev/sda2
/dev/sda2
[Email protected] ~]# Ls/dev/sda3
Ls:cannot access/dev/sda3:no such file or directory
The role of wildcards here is you're not sure how many partitions, partition numbers, he can help you determine
* Match 0 or more characters
? Match any single character
[0-9] numbers within the matched range
[ABC] matches the given character
Instance:
[Email protected] ~]# ls/dev/sda*
/dev/sda/dev/sda1/dev/sda2
[Email protected] ~]# LS/DEV/SDA?
/dev/sda1/dev/sda2
[[email protected] ~]# ls/dev/sda[0-9]
/dev/sda1/dev/sda2
[[email protected] ~]# LS/DEV/SD[ABC]
/dev/sda
[Email protected] ~]# LS/DEV/SD[ABC]?
/dev/sda1/dev/sda2
[Email protected] ~]# ls/dev/sd[abc]*
/dev/sda/dev/sda1/dev/sda2
In addition Bash supports many special character extensions:
\ (backslash) escapes a single character later
"(single quote) to escape all characters
"" (double quote) variable is still in effect
"(anti-quote) EXECUTE command statement
Variable takes effect:
[Email protected] ~]# price=5
[Email protected] ~]# echo "Price is $Price"
Price is 5
But if you want to show the price as $ $, and it conflicts with the variable, it's time to use the escape character \ Backslash
[[email protected] ~]# echo "Price is $ $Price"
Price is 6892Price
[Email protected] ~]# echo "Price is \$ $Price"
Price is $
Use single quotation marks to escape all characters
[Email protected] ~]# echo ' Price is \$ $Price '
Price is \$ $Price
Use "to execute command statements
[[email protected] ~]# echo ' uname-a '
Linux msl23-linux.com 3.10.0-123.el7.x86_64 #1
SMP Mon May 5 11:16:57 EDT x86_64 x86_64 x86_64 gnu/linux
[[email protected] ~]# echo ' uname-r '
3.10.0-123.el7.x86_64
linux[Base]-10-command-line wildcard [01]