File Wildcard Use Example
* Match 0 or more characters
~]# ls x* such as searching for files or directories that begin with X
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/85/2A/wKioL1ebPLKj8UvBAAAzIiYVDSI287.png "title=" @~_ Io6owxeun1ta_r%iali4.png "alt=" Wkiol1ebplkj8uvbaaaziiyvdsi287.png "/>
? Match any single character
~]# ls x? Search for files that begin with X or a single character in a directory
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/85/2A/wKiom1ebPe7wOql8AAAeuIR6Js4912.png "title=" zv7% UX3RGT)}) 3 (}s} $I]xi.png "alt=" Wkiom1ebpe7woql8aaaeuir6js4912.png "/>
^ Get Reverse value
~ Current User Home Directory
~]# CD Back home directory
650) this.width=650; "src=" http://s2.51cto.com/wyfs02/M02/85/2A/wKioL1ebPmnh4QndAAAMcK0WGJg670.png "title=" 0) C5] }u3j ' 3vn8htza9eeq.png "alt=" Wkiol1ebpmnh4qndaaamck0wgjg670.png "/>
~username ~]# CD ~makangbo back to user home directory
~]# ll ~/can also access directories or files
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/85/2A/wKiom1ebPxmAlCuQAABLONwndO8545.png "title=" ju[z_) 4h_) $ (_5) r$p9]5xy.png "alt=" Wkiom1ebpxmalcuqaablonwndo8545.png "/>
~+ Current Working Directory
/]# CD ~+ similar to. Show Current working directory
/]# ls ~+/root can also access directories or files
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/85/2A/wKiom1ebQevwAZo9AACJOX5ps-4176.png "title=" {t$]7% L~9z9l$kwf1v0y9on.png "alt=" Wkiom1ebqevwazo9aacjox5ps-4176.png "/>
~-Previous working directory
/]# CD For example I first CD back home directory then ~]# CD ~-input CD ~-back to previous working directory
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/85/2A/wKioL1ebQtPgOOy_AAAxOxU_1C4931.png "title=" r@y7$ 7anpg80ap3wcj[iqb2.png "alt=" Wkiol1ebqtpgooy_aaaxoxu_1c4931.png "/>
~]# ll ~-/root can access the directory or file
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/85/2A/wKioL1ebRGGQt2cGAABZ5iw0-9E876.png "title=" AMCHNL5DHAXWS) _l) nzn23r.png "alt=" Wkiol1ebrggqt2cgaabz5iw0-9e876.png "/>
[0-9] matching a range of numbers
~]# ll x[0-9] access to see the file or directory ending with x [0-9] as a number
~]# ll X[1A3] Access view beginning with x [1;a;3;] File or directory with the mantissa as the result
~]# LL X[^1A3] Take an anti-access file or directory ' ^ ' that starts with x not [1a3]
[A-z] letter range
~]# ll X[a-c] access to view files or directories ending with the [a-c] letter beginning with X
The middle includes uppercase letter AB and so on, of course the range written to lowercase C certainly not to uppercase C
[A-z] format "AABBC" in the middle of a small letter A includes the range of the upper case AB to the lowercase letter C
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/85/2A/wKioL1ebRezgi2jKAACAk9M6nMQ097.png "title=") gear_ eeo7r ' 04_$fj362m2.png "alt=" Wkiol1ebrezgi2jkaacak9m6nmq097.png "/>
*: Any of the characters
?: any single character
[]: Specify any single character in the range
[^]: Specify a single character outside the range
Pre-defined character classes: # Man 7 glob
[:d igit:] Any number, equivalent to 0-9 between ~]# ll xiaomag[[:d Igit:]]
To access files that end with a ' number range ' for files beginning with Xiaomag
[: Lower:] Any lowercase letter ~]# ll Xiaomag[[:lower:]] access to Xia Omag files beginning with a ' lowercase letter A-Z range ' end file
[: Upper:] Any capital letter ~]# ll Xiaomag[[:upper:]] access to Xia Omag files beginning with ' capital letter A-Z range '
[: Aplha:] Any uppercase and lowercase letter ~]# ll Xiaomag[[:alpha:]] Access the file beginning with the Xiaomag ' size Write the letter Aa-zz within the range first small after large ' for the end of the file
[: Alnum:] Any number or letter ~]# ll Xiaomag[[:alnum:]] access to XIAOM Files beginning with AG end with ' any number or uppercase letter '
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/85/2A/wKioL1ebSuCC-SBZAARQL2-c00k657.jpg "title=" Copytoqq.jpg "alt=" Wkiol1ebsucc-sbzaarql2-c00k657.jpg "/>
Practice
1: Displays all files or directories in the/var directory that begin with M, end with a lowercase letter, and have at least one digit (can have other characters) appear in the middle.
~]# ls-1/var/m*[[:d igit:]]*[[:lower:]]
(arranged in one file per line) *: matches 0 or more characters; [[:d Igit:]] any number begins; [[: Lower:]] lowercase Letter
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/85/2A/wKioL1ebTIeBsCOnAAAuZMwyAfw099.png "title=" $LO) Kxuj[cx329ew4@012k8.png "alt=" Wkiol1ebtiebsconaaauzmwyafw099.png "/>
2: Displays files or directories that start with any number in the/etc directory and end with a non-numeric number.
~]# ls-l/etc/[[:d igit:]]*[^[:d igit:]]
(shown by a long list) number ^ Take the inverse, take the inverse non-numeric
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/85/2A/wKiom1ebTSXR8CFBAAAjGlc82ac238.png "title=" 3gos{ 5pxgtoz}jazisl_tw9.png "alt=" Wkiom1ebtsxr8cfbaaajglc82ac238.png "/>
3: Display in/etc directory, starting with a non-letter, followed by a letter and any other arbitrary length of any character file or directory.
~]# ls-l/etc/[^[:alpha:]]*[[:alpha:]]
(shown in long list) ^ takes the value of the inverse of any letter (meaning to get a non-letter start)
Then follow an arbitrary length; any character; any letter;
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/85/2A/wKioL1ebTeizptKzAAAjp4jf5No752.png "title=" [' 99q@upqs177jag[h) _xlq.png "alt=" Wkiol1ebteizptkzaaajp4jf5no752.png "/>
4: Displays all files or directories in the/etc directory that begin with a non-numeric end of M.
~]# ls-l/etc/m*[^[:d igit:]]
(shown by a long list) m starts with * matches 0 or more characters; ^ The value of the inverse number (that is, not the number) is displayed m****
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/85/2A/wKiom1ebTpDwDZ78AAA7Xu-YVxI974.png "title=" [JA] Gm2ad}3ew (8 ' bxch$80.png "alt=" Wkiom1ebtpdwdz78aaa7xu-yvxi974.png "/>
5: Displays all files or directories ending with. D in the/etc directory
~]# LS-LD/ETC/[[:ALNUM:]]*.D
(LD only displays the list directory itself, does not display the content) any number or letter beginning;
* Match 0 or more characters with. D as the end of all files or directories
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/85/2B/wKioL1ebVcXCLWcgAACMH8GvDo4866.png "title=" H0L9TVJ}X{SU] (ec~1ktowe.png "alt=" Wkiol1ebvcxclwcgaacmh8gvdo4866.png "/>
6: Displays all. conf End with/etc directory, and the file or directory starting with, M,n,r,p
~]# ll/etc/[m:r:n:p]*.conf
(Open file list) The title asks for a file that begins with M,n,r,p and uses [M:r:n:p] to surround the required characters with * (all) and end with. conf
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/85/2B/wKioL1ebV2vwqVqeAACk8G2u3v0676.png "title=" 02@$ O2ysplz8z7{24oj4qye.png "alt=" Wkiol1ebv2vwqvqeaack8g2u3v0676.png "/>
Lay the foundation for building tall buildings, keep your good habits and improve your bad habits! 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0058.gif "alt=" J_0058.gif "/>
Little Marco (Xiaomag)
This article from "Pony Brother Linux system operation and Maintenance" blog, reproduced please contact the author!
CentOS file wildcard; predefined characters; a simple example