Globbing: File name wildcard (whole file name match, not part)Match pattern: metacharacters*: matches any character of any lengthpa*, *pa*, *pa, *p*a*PA, PAA, passwd?: matches any single characterPa??? PA, P?a, P?a?PA, PAA, passwd[]: matches any single character within the specified rangeThere are several special formats:[A-z], [A-z], [0-9], [a-z0-9][[: Upper:]]: All uppercase letters[[: Lower:]]: All lowercase letters[[: Alpha:]]: All letters[[:d Igi
:]]: All lowercase letters
[[: Alpha:]]: All letters
[[:d igit:]]: All numbers [[: Alnum:]]: All letters and numbers
[[:space:]]: all whitespace characters
[[: Punct:]]: All punctuation
It is necessary to note that the wildcard looks a bit like a regular expression statement, but unlike regular expressions, it cannot be confused with each other. The wildcard character can be interpreted as a shell special code.And the only thing involved is *,? ,[] these ki
Text Template match
========================================================
Text Template matching can be understood as a wildcard. I think you have used the built-in search function in windows.
*An asterisk represents one or more characters.
?A question mark represents a character.
A template is also a parameter frequently used by selenes commands. A template allows you to use special characters to describe the expected value, rather than accurately describe the expected value.
The
double brackets)
-Lt
Number comparison
=
Equal strings
=
String comparison in Globbing mode (used only in double brackets, refer to the following)
= ~
Use regular expressions to compare strings (used only in double brackets)
-N
Non-null string
-Z
Null string
-Eq
Equal number
-Ne
Numbers
Brackets:
[ "${name}" \> "a" -o ${name} \
Double brackets
[[ "${
Text template Matching
=======================================
Text template matching can actually be understood as wildcard characters. I think everyone has used the search function of the Windows system itself.
* The asterisk represents one or more characters.
? The question mark represents a character.
A template is also a parameter that is often used by selenes commands; The template allows you to use special characters to describe expectations rather than accurately illustrate expectat
filename patterns to be excluded from matching in globbing. $ GROUPSGroups current user belongs toThis is a listing (array) of the group id numbers f Or current user, as recorded in/etc/passwd and/etc/group. root # echo $ GROUPS0root # echo $ {GROUPS [1]} 1 root # echo $ {GROUPS [5]} 6 $ HOMEHome directory of the user, usually/home/username (see Example 10-7) $ HOSTNAMEThe hostname command assigns the system host name at bootup in an init script. how
list of search paths available to the cd command, similar in function to the $ PATHvariable for binaries. the $ CDPATH variable may be set in the local ~ /. Bashrc file. $ DIRSTACKThe top value in the directory stack [41] (affected by pushd and popd) This builtin variable corresponds to the dirs command, however dirs shows the entire contents of thedirectory stack. $ EDITORThe default editor invoked by a script, usually vi or emacs. $ EUID "valid tive" user ID numberIdentification number of wha
), such as: (("$a" >= "$b"))Small data comparisons can be used with awkstring comparison= equals, such as: if ["$a" = "$b"]= = equals, such as: if ["$a" = = "$b"], and = equivalentNote: The behavior of the = = function is different in [[]] and [], as follows:1 [[$a = = z*]] # if $ A starts with "Z" (pattern match) then true2 [[$a = = "z*"] # if $ A equals z* (character match) Then the result is true34 [$a = = z*] # File globbing and word splitting wil
: (("$a" > "$b")>= greater than or equal (requires double brackets), such as: (("$a" >= "$b"))string comparison= equals, such as: if ["$a" = "$b"]= = equals, such as: if ["$a" = = "$b"], and = equivalentNote: The behavior of the = = function is different in [[]] and [], as follows:1 [[$a = = z*]] # if $ A starts with "Z" (pattern match) then true2 [[$a = = "z*"] # if $ A equals z* (character match) Then the result is true34 [$a = = z*] # File globbing
), such as: (("$a" >= "$b"))Small data comparisons can be used with awkstring comparison= equals, such as: if ["$a" = "$b"]= = equals, such as: if ["$a" = = "$b"], and = equivalentNote: The behavior of the = = function is different in [[]] and [], as follows:1 [[$a = = z*]] # if $ A starts with "Z" (pattern match) then true2 [[$a = = "z*"] # if $ A equals z* (character match) Then the result is true34 [$a = = z*] # File globbing and word splitting wil
quotes to tell the interpreter " $text is a string." The interpreter does not convert it to a blank or \n delimited list of arguments or anything else. So, without trick in bash, echo $text you can keep line breaks straight. However, as we said in the previous section, we need an extra work to ensure that the output is the original text that is not escaped, and that is the -E option:echo -E $textFrom here we see that variables in zsh are not automatically cut into words and then in the form of
match), then the result is true34 [$a = = z*] # File globbing and word splitting will occur5 ["$a" = "z*"] # if $a equals z* (character match), then the result is trueA little explanation, about the file globbing is a shorthand for documents, such as "*.c" is, and so on. But file globbing is not a strict regular expression, although in most cases the structure i
3
4 [$a = = z*] # File globbing and word splitting will occur
5 ["$a" = "z*"] # if $a equals z* (character match), then the result is true
A little explanation, about the file globbing is a shorthand for documents, such as "*.c" is, and so on.
But file globbing is not a strict regular expression, although in most cases the structure is more like.
!= is not equal
["$a" = "$b"]
= = equals, such as: if ["$a" = = "$b"], and = equivalent
Note: the function of = = = is different in [[]] and [], as follows:
1 [[$a = = z*]] # If $a starts with "Z" (pattern match) then it will be true
2 [[$a = = "z*"]] # if $a equals z* (character match), then the result is true
3
4 [$a = = z*] # File globbing and word splitting will occur
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/
5
in [[]] and [] are different, as follows:1[[$a = = z*]] # if $ A"Z"Start (pattern match) then thetrue2[[$a = ="z*"] # if $ A equals z* (character match), then the result istrue34[$a = = z*] # File globbing and Word splitting will occur5["$a"=="z*"] # if $ A equals z* (character match), then the result istruea little explanation, about file globbing is a shorthand for documents, such as"*.c"is, again like ~
globbing and word splitting will occur5 ["$ A" = "z *"] # If $ A is equal to z * (character matching), the result is true.For a bit of explanation, file globbing is a stenographer of files, for example, "*. c" is, and then ~ Yes.But file globbing is not a strict regular expression, although the structure is similar in most cases.! = Not equal to, such as: If ["$
Grep, egrep, and regular expressions
All files in Linux: text files are critical and commonly used for text file search.
Linux text search tools: grep, egrep, fgrep, and text search are used to search text files.
File name search is a bash feature in linux. globbing and file name configuration are similar in windows, but powerful. It is generally used with the ls command. See the following video: Basic bash features (01)
error [: =: unary operator expected
[[$ A = z *] # true if $ a starts with "z" (pattern matching)
[[$ A = "z *"] # If $ a is equal to z * (character matching), the result is true.
[$ A = z *] # File globbing and word splitting will occur
["$ A" = "z *"] # If $ a is equal to z * (character matching), the result is true.
About File globbing:
For a bit of explanation, Fileglobbing is a stenographer of files
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.