Shell regular expressions use detailed explanation

  

debian:~/test# { a=1; b=2; }debian:~/test# echo $a$b12debian:~/test# ( a=3 b=4 ) The values ​​of # a and b are not changed in the current shell. debian:~/test# echo $a$b12&& “&&quoquo; After successful execution, the exit status is 0, then continue to the next command| |  “ or & rdquo; Exit status is not 0, that is, the execution is unsuccessful, then continue to the next command;; “ non & rdquo; whether successful or not, will continue to the next command regular expression: \\ escaping [[ \\ \\ Match \\ ]]^ Match start position [[ ^a match starts with a]]$ Match end position [[ $a match a end]]* Match previous subexpression 0 or more times [[min 0 times, Up to N times]]+ Matches the previous subexpression 1 or more times [[Minimum 1 time, Up to N times]]? Matches the previous subexpression 0 times or 1 time [[Either, or not]]{n} Matches the number of previous subexpressions [[ a{3} matches aaa ]]{n,} matches at least N times [[ a{2,} matches aa or aaa]] matches aa or aa…N both a and above Matches the number of times {n,m} exactly matches the subexpression [[ a{1,2} matches a and aa]]. matches all single characters except [<;n”[[ matching behavior [.\ ] ]]a| b matches a or bdebian:~/test# cat abcabccbadebian:~/test# grep -E ‘(a| c)b(c| a) & rsquo; abcabccba[abc] matches the set character set debian:~/test# cat abcabccbaABCdebian:~/test# grep -E ‘[abc]‘ abcabccba[^abc] does not match the set character Set debian:~/test# cat 123abc123debian:~/test# grep -E ‘[^123]‘ 123abc[az] [AZ] [0-9] = [[:alnum:]]

Copyright © Windows knowledge All Rights Reserved