Introduction to regular expressions and wildcards

Wildcards and Regular Expressions

1. wildcard (wild-card pattern) is typically used to match the file name, which is parsed by the shell, normally used to find (search files), LS (directory), CP (copy), Music Videos (mobile) and the like.
Common shell wildcards have
*zero or more characters
to match any one character
~of the current user's home directory of
~+the current working directory
~-before a working directory
[list]matches any single character list in a
[^list]match list in addition to any single character
[0-9]or [:digit:]0-9 match
[az] or [: Lower:] lowercase letters az match
[A-Z]or [:upper:]capital letters AZ match
[a-z][A-Z]or [:alpha:]matches any case letters
[:alnum:]any number or letter
[:blank:]horizontal whitespace
[:space:]horizontal or vertical blanking character
[:punct:]punctuation
[:print:]printable symbols
[:cntrl:]: control (non-printing) characters
[:graph:]: graphic character
[:xdigit:]: ten hex character
sometimes want to become a general wildcard characters do not need to use it then they would have to spend the transfer symbol
'' single quotation marks, all of its internal wildcards will be turned off
, "" double quotes, which only allowed inside special shell characters: $ for parameter substitution
\ backslash, also known as escaping, remove the special meaning of the wildcard followed behind.
2. Regular Expressions
Regular expressions are used to retrieve, replace the text in line with those of a model (the rules), such as sed, grep, etc., regular expressions and wildcards some projects is quite similar, please note the difference.
^The first line
$end of the line
.of any single character
[]in a single character in brackets
[^]any single character in brackets in addition to
^[]the first line of characters within square brackets to
[]$the end of line character in brackets in
*the preceding repetitions uncertain characters
\+preceding character was repeated one more uncertain times
\?preceding character 0 or 1 is repeated
\escape
.*of any length character
\{n\}before the character is repeated n times
\{n,\}before the character is repeated n times or more
\{m,n\}before the character is repeated n times and the m times between
[::] internal wildcard essentially the same regular expression.

Guess you like

Origin blog.51cto.com/14451141/2428450