{"id":71979,"date":"2023-09-25T09:52:55","date_gmt":"2023-09-25T01:52:55","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=71979"},"modified":"2023-09-25T09:52:55","modified_gmt":"2023-09-25T01:52:55","slug":"regular-expressions-in-grep","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/regular-expressions-in-grep.html","title":{"rendered":"grep \u547d\u4ee4\u7cfb\u5217\uff1agrep \u4e2d\u7684\u6b63\u5219\u8868\u8fbe\u5f0f"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728 Linux \u3001\u7c7b Unix \u7cfb\u7edf\u4e2d\u6211\u8be5\u5982\u4f55\u4f7f\u7528 Grep \u547d\u4ee4\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5462\uff1fLinux \u9644\u5e26\u6709 GNU grep \u547d\u4ee4\u5de5\u5177\uff0c\u5b83\u652f\u6301\u6269\u5c55\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u800c\u4e14 GNU grep \u5728\u6240\u6709\u7684 Linux \u7cfb\u7edf\u4e2d\u90fd\u662f\u9ed8\u8ba4\u6709\u7684\u3002Grep \u547d\u4ee4\u88ab\u7528\u4e8e\u641c\u7d22\u5b9a\u4f4d\u5b58\u50a8\u5728\u60a8\u670d\u52a1\u5668\u6216\u5de5\u4f5c\u7ad9\u4e0a\u7684\u4efb\u4f55\u4fe1\u606f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u6b63\u5219\u8868\u8fbe\u5f0f<\/strong><\/div>\n

\u6b63\u5219\u8868\u8fbe\u5f0f\u5c31\u662f\u7528\u4e8e\u5339\u914d\u6bcf\u884c\u8f93\u5165\u7684\u4e00\u79cd\u6a21\u5f0f\uff0c\u6a21\u5f0f\u662f\u6307\u4e00\u4e32\u5b57\u7b26\u5e8f\u5217\u3002\u4e0b\u9762\u662f\u8303\u4f8b\uff1a<\/p>\n

^w1\r\nw1|w2\r\n[^ ]\r\n<\/pre>\n
grep \u6b63\u5219\u8868\u8fbe\u5f0f\u793a\u4f8b<\/strong><\/div>\n

\u5728 \/etc\/passswd \u76ee\u5f55\u4e2d\u641c\u7d22 'vivek'<\/p>\n

grep vivek \/etc\/passwd\r\n<\/pre>\n

\u8f93\u51fa\u4f8b\u5b50:<\/p>\n

vivek:x:1000:1000:Vivek Gite,,,:\/home\/vivek:\/bin\/bash\r\nvivekgite:x:1001:1001::\/home\/vivekgite:\/bin\/sh\r\ngitevivek:x:1002:1002::\/home\/gitevivek:\/bin\/sh\r\n<\/pre>\n

\u641c\u7d22\u5927\u5c0f\u5199\u4efb\u610f\u7684 vivek(\u5373\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u7684\u641c\u7d22)<\/p>\n

grep -i -w vivek \/etc\/passwd\r\n<\/pre>\n

\u641c\u7d22\u5927\u5c0f\u5199\u4efb\u610f\u7684 vivek \u6216 raj<\/p>\n

grep -E -i -w 'vivek|raj' \/etc\/passwd\r\n<\/pre>\n

\u4e0a\u9762\u6700\u540e\u7684\u4f8b\u5b50\u663e\u793a\u7684\uff0c\u5c31\u662f\u4e00\u4e2a\u6269\u5c55\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u6a21\u5f0f\u3002<\/p>\n

\u951a\u70b9<\/strong><\/div>\n

\u4f60\u53ef\u4ee5\u5206\u522b\u4f7f\u7528 ^ \u548c $ \u7b26\u53f7\u6765\u6b63\u5219\u5339\u914d\u8f93\u5165\u884c\u7684\u5f00\u59cb\u6216\u7ed3\u5c3e\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u641c\u7d22\u663e\u793a\u4ec5\u4ec5\u4ee5 vivek \u5f00\u59cb\u7684\u8f93\u5165\u884c\uff1a<\/p>\n

grep ^vivek \/etc\/passwd\r\n<\/pre>\n

\u8f93\u51fa\u4f8b\u5b50:<\/p>\n

vivek:x:1000:1000:Vivek Gite,,,:\/home\/vivek:\/bin\/bash\r\nvivekgite:x:1001:1001::\/home\/vivekgite:\/bin\/sh\r\n<\/pre>\n

\u4f60\u53ef\u4ee5\u4ec5\u4ec5\u53ea\u641c\u7d22\u51fa\u4ee5\u5355\u8bcd vivek \u5f00\u59cb\u7684\u884c\uff0c\u5373\u4e0d\u663e\u793a vivekgit\u3001vivekg \u7b49\uff08LCTT \u8bd1\u6ce8\uff1a\u5373\u8be5\u5355\u8bcd\u540e\u9762\u662f\u7a7a\u683c\u3001\u7b26\u53f7\u7b49\u82f1\u6587\u7684\u5355\u8bcd\u5206\u9694\u7b26\u3002\uff09<\/p>\n

grep -w ^vivek \/etc\/passwd\r\n<\/pre>\n

\u627e\u51fa\u4ee5\u5355\u8bcd word \u7ed3\u5c3e\u7684\u884c\uff1a<\/p>\n

grep 'foo$' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u5339\u914d\u4ec5\u4ec5\u53ea\u5305\u542b foo \u7684\u884c\uff1a<\/p>\n

grep '^foo$' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u5982\u4e0b\u6240\u793a\u7684\u4f8b\u5b50\u53ef\u4ee5\u641c\u7d22\u7a7a\u884c\uff1a<\/p>\n

grep '^$' \u6587\u4ef6\u540d\r\n<\/pre>\n
\u5b57\u7b26\u7c7b<\/strong><\/div>\n

\u5339\u914d Vivek \u6216 vivek\uff1a<\/p>\n

grep '[vV]ivek' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u6216\u8005<\/p>\n

grep '[vV][iI][Vv][Ee][kK]' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u4e5f\u53ef\u4ee5\u5339\u914d\u6570\u5b57 (\u5373\u5339\u914d vivek1 \u6216 Vivek2 \u7b49\u7b49):<\/p>\n

grep -w '[vV]ivek[0-9]' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u53ef\u4ee5\u5339\u914d\u4e24\u4e2a\u6570\u5b57\u5b57\u7b26(\u5373 foo11\u3001foo12 \u7b49):<\/p>\n

grep 'foo[0-9][0-9]' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u4e0d\u4ec5\u4ec5\u5c40\u9650\u4e8e\u6570\u5b57\uff0c\u4e5f\u80fd\u5339\u914d\u81f3\u5c11\u4e00\u4e2a\u5b57\u6bcd\u7684:<\/p>\n

grep '[A-Za-z]' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u663e\u793a\u542b\u6709 \"w\" \u6216 \"n\" \u5b57\u7b26\u7684\u6240\u6709\u884c\uff1a<\/p>\n

grep [wn] \u6587\u4ef6\u540d\r\n<\/pre>\n

\u653e\u5728\u62ec\u53f7\u5185\u7684\u8868\u8fbe\u5f0f\uff0c\u5373\u5305\u5728 \"[:\" \u548c \":]\" \u4e4b\u95f4\u7684\u5b57\u7b26\u7c7b\u7684\u540d\u5b57\uff0c\u5b83\u8868\u793a\u7684\u662f\u5c5e\u4e8e\u6b64\u7c7b\u7684\u6240\u6709\u5b57\u7b26\u5217\u8868\u3002\u6807\u51c6\u7684\u5b57\u7b26\u7c7b\u540d\u79f0\u5982\u4e0b\uff1a<\/p>\n

[:alnum:]<\/pre>\n

- \u5b57\u6bcd\u6570\u5b57\u5b57\u7b26<\/p>\n

[:alpha:]<\/pre>\n

- \u5b57\u6bcd\u5b57\u7b26<\/p>\n

[:blank:]<\/pre>\n

- \u7a7a\u5b57\u7b26: \u7a7a\u683c\u952e\u7b26 \u548c \u5236\u8868\u7b26<\/p>\n

[:digit:]<\/pre>\n

- \u6570\u5b57: '0 1 2 3 4 5 6 7 8 9'<\/p>\n

[:lower:]<\/pre>\n

- \u5c0f\u5199\u5b57\u6bcd: 'a b c d e f g h i j k l m n o p q r s t u v w x y z'<\/p>\n

[:space:]<\/pre>\n

- \u7a7a\u683c\u5b57\u7b26: \u5236\u8868\u7b26\u3001\u6362\u884c\u7b26\u3001\u5782\u76f4\u5236\u8868\u7b26\u3001\u6362\u9875\u7b26\u3001\u56de\u8f66\u7b26\u548c\u7a7a\u683c\u952e\u7b26<\/p>\n

[:upper:]<\/pre>\n

- \u5927\u5199\u5b57\u6bcd: 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'<\/p>\n

\u5728\u8fd9\u4e2a\u4f8b\u5b50\u6240\u793a\u7684\u662f\u5339\u914d\u6240\u6709\u5927\u5199\u5b57\u6bcd:<\/p>\n

grep '[:upper:]' \u6587\u4ef6\u540d\r\n<\/pre>\n
\u901a\u914d\u7b26<\/strong><\/div>\n

\u4f60\u53ef\u4ee5\u4f7f\u7528 \".\" \u6765\u5339\u914d\u5355\u4e2a\u5b57\u7b26\u3002\u4f8b\u5b50\u4e2d\u5339\u914d\u4ee5 \"b\" \u5f00\u5934\u4ee5 \"t\" \u7ed3\u5c3e\u76843\u4e2a\u5b57\u7b26\u7684\u5355\u8bcd\uff1a<\/p>\n

grep '\/<b.t\/>' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u5728\u8fd9\u513f,<\/p>\n

\u5339\u914d\u5355\u8bcd\u524d\u9762\u7684\u7a7a\u5b57\u7b26\u4e32
\n\u5339\u914d\u5355\u8bcd\u540e\u9762\u7684\u7a7a\u5b57\u7b26\u4e32<\/p>\n

\u6253\u5370\u51fa\u53ea\u6709\u4e24\u4e2a\u5b57\u7b26\u7684\u6240\u6709\u884c:<\/p>\n

grep '^..$' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u663e\u793a\u4ee5\u4e00\u4e2a\u70b9\u548c\u4e00\u4e2a\u6570\u5b57\u5f00\u5934\u7684\u884c\uff1a<\/p>\n

grep '^\/.[0-9]' \u6587\u4ef6\u540d\r\n<\/pre>\n
\u70b9\u5b57\u7b26\u8f6c\u4e49<\/strong><\/div>\n

\u4e0b\u9762\u8981\u5339\u914d\u5230 IP \u5730\u5740\u4e3a 192.168.1.254 \u7684\u6b63\u5219\u5f0f\u662f\u4e0d\u6b63\u786e\u7684\uff1a\uff08LCTT \u8bd1\u6ce8\uff1a\u53ef\u4ee5\u5339\u914d\u5230\u8be5 IP \u5730\u5740\uff0c\u4f46\u662f\u4e5f\u6709\u53ef\u80fd\u5339\u914d\u5230\u95f4\u9694\u7b26\u53f7\u4e0d\u662f\u70b9\u7684\u7c7b\u4f3c\u683c\u5f0f\uff09<\/p>\n

grep '192.168.1.254' \/etc\/hosts\r\n<\/pre>\n

\u4e09\u4e2a\u70b9\u5b57\u7b26\u90fd\u9700\u8981\u8f6c\u4e49\uff1a<\/p>\n

grep '192\/.168\/.1\/.254' \/etc\/hosts\r\n<\/pre>\n

\u4e0b\u9762\u7684\u4f8b\u5b50\u53ea\u80fd\u5339\u914d\u51fa IP \u5730\u5740\uff1a\uff08LCTT \u8bd1\u6ce8\uff1a\u5b9e\u9645\u4e0a\u7531\u4e8e IP \u5730\u5740\u4e2d\u6570\u5b57\u7684\u53d6\u503c\u8303\u56f4\uff0c\u8be5\u6b63\u5219\u8868\u8fbe\u5f0f\u5e76\u4e0d\u7cbe\u786e\uff09<\/p>\n

egrep '[[:digit:]]{1,3}\/.[[:digit:]]{1,3}\/.[[:digit:]]{1,3}\/.[[:digit:]]{1,3}' \u6587\u4ef6\u540d\r\n<\/pre>\n
\u600e\u4e48\u6837\u641c\u7d22\u4ee5\u201c-\u201d \u7b26\u53f7\u5f00\u5934\u7684\u5339\u914d\u6a21\u5f0f\uff1f<\/strong><\/span><\/div>\n

\u8981\u4f7f\u7528 -e \u9009\u9879\u6765\u641c\u7d22\u5339\u914d '--test--' \u5b57\u7b26\u4e32\uff0c\u5982\u679c\u4e0d\u4f7f\u7528 -e \u9009\u9879\uff0cgrep \u547d\u4ee4\u4f1a\u8bd5\u56fe\u628a '--test--' \u5f53\u4f5c\u81ea\u5df1\u7684\u9009\u9879\u53c2\u6570\u6765\u89e3\u6790\uff1a<\/p>\n

grep -e '--test--' \u6587\u4ef6\u540d\r\n<\/pre>\n
\u600e\u4e48\u4f7f\u7528 grep \u7684\u201c\u6216\u201d\u5339\u914d?<\/strong><\/span><\/div>\n

\u4f7f\u7528\u5982\u4e0b\u7684\u8bed\u6cd5\uff1a<\/p>\n

grep -E 'word1|word2' \u6587\u4ef6\u540d\r\n\u6216\r\negrep 'word1|word2' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u6216\u8005\u662f<\/p>\n

grep 'word1\/|word2' \u6587\u4ef6\u540d\r\n<\/pre>\n
\u600e\u4e48\u4f7f\u7528 grep \u7684\u201c\u548c\u201d\u5339\u914d?<\/strong><\/span><\/div>\n

\u4f7f\u7528\u4e0b\u9762\u7684\u8bed\u6cd5\u6765\u663e\u793a\u65e2\u5305\u542b 'word1' \u53c8\u5305\u542b 'word2' \u7684\u6240\u6709\u884c<\/p>\n

grep 'word1' \u6587\u4ef6\u540d | grep 'word2'\r\n<\/pre>\n
\u600e\u4e48\u6837\u4f7f\u7528\u5e8f\u5217\u68c0\u6d4b?<\/strong><\/span><\/div>\n

\u4f7f\u7528\u5982\u4e0b\u7684\u8bed\u6cd5\uff0c\u60a8\u53ef\u4ee5\u68c0\u6d4b\u4e00\u4e2a\u5b57\u7b26\u5728\u5e8f\u5217\u4e2d\u91cd\u590d\u51fa\u73b0\u6b21\u6570\uff1a<\/p>\n

{N}\r\n{N,}\r\n{min,max}\r\n<\/pre>\n

\u8981\u5339\u914d\u5b57\u7b26 \u201cv\" \u51fa\u73b0\u4e24\u6b21\uff1a<\/p>\n

egrep \"v{2}\" \u6587\u4ef6\u540d\r\n<\/pre>\n

\u4e0b\u9762\u7684\u547d\u4ee4\u80fd\u5339\u914d\u5230 \"col\" \u548c \"cool\" \uff1a<\/p>\n

egrep 'co{1,2}l' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u4e0b\u9762\u7684\u547d\u4ee4\u5c06\u4f1a\u5339\u914d\u51fa\u81f3\u5c11\u6709\u4e09\u4e2a 'c' \u5b57\u7b26\u7684\u6240\u6709\u884c\u3002<\/p>\n

egrep 'c{3,}' \u6587\u4ef6\u540d\r\n<\/pre>\n

\u4e0b\u9762\u7684\u4f8b\u5b50\u4f1a\u5339\u914d 91-1234567890\uff08\u5373\u4e8c\u4e2a\u6570\u5b57-\u5341\u4e2a\u6570\u5b57\uff09 \u8fd9\u79cd\u683c\u5f0f\u7684\u624b\u673a\u53f7\u3002<\/p>\n

grep \"[[:digit:]]\/{2\/}[ -]\/?[[:digit:]]\/{10\/}\" \u6587\u4ef6\u540d\r\n<\/pre>\n
\u600e\u4e48\u6837\u4f7f grep \u547d\u4ee4\u9ad8\u4eae\u663e\u793a\uff1f<\/strong><\/span><\/div>\n

\u4f7f\u7528\u5982\u4e0b\u7684\u8bed\u6cd5\uff1a<\/p>\n

grep --color \u6b63\u5219\u8868\u8fbe\u5f0f \u6587\u4ef6\u540d\r\n<\/pre>\n
\u600e\u4e48\u6837\u4ec5\u4ec5\u53ea\u663e\u793a\u5339\u914d\u51fa\u7684\u5b57\u7b26\uff0c\u800c\u4e0d\u662f\u5339\u914d\u51fa\u7684\u884c\uff1f<\/strong><\/span><\/div>\n

\u4f7f\u7528\u5982\u4e0b\u8bed\u6cd5\uff1a<\/p>\n

grep -o \u6b63\u5219\u8868\u8fbe\u5f0f \u6587\u4ef6\u540d\r\n<\/pre>\n
\u6b63\u5219\u8868\u8fbe\u5f0f\u9650\u5b9a\u7b26<\/strong><\/div>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\u9650\u5b9a\u7b26<\/th>\n\u63cf\u8ff0<\/th>\n<\/tr>\n<\/thead>\n
.<\/td>\n\u5339\u914d\u4efb\u610f\u7684\u4e00\u4e2a\u5b57\u7b26\u3002<\/td>\n<\/tr>\n
?<\/td>\n\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f\uff0c\u6700\u591a\u4e00\u6b21\u3002<\/td>\n<\/tr>\n
*<\/td>\n\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f\u96f6\u6b21\u6216\u591a\u6b21\u3002<\/td>\n<\/tr>\n
+<\/td>\n\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f\u4e00\u6b21\u6216\u591a\u6b21\u3002<\/td>\n<\/tr>\n
{N}<\/td>\n\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f N \u6b21\u3002<\/td>\n<\/tr>\n
{N,}<\/td>\n\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f N \u6b21\u5230\u591a\u6b21\u3002<\/td>\n<\/tr>\n
{N,M}<\/td>\n\u5339\u914d\u524d\u9762\u7684\u5b50\u8868\u8fbe\u5f0f N \u5230 M \u6b21\uff0c\u81f3\u5c11 N \u6b21\u81f3\u591a M \u6b21\u3002<\/td>\n<\/tr>\n
-<\/td>\n\u53ea\u8981\u4e0d\u662f\u5728\u5e8f\u5217\u5f00\u59cb\u3001\u7ed3\u5c3e\u6216\u8005\u5e8f\u5217\u7684\u7ed3\u675f\u70b9\u4e0a\uff0c\u8868\u793a\u5e8f\u5217\u8303\u56f4\u3002<\/td>\n<\/tr>\n
^<\/td>\n\u5339\u914d\u4e00\u884c\u5f00\u59cb\u7684\u7a7a\u5b57\u7b26\u4e32\uff1b\u4e5f\u8868\u793a\u5b57\u7b26\u4e0d\u5728\u8981\u5339\u914d\u7684\u5217\u8868\u4e2d\u3002<\/td>\n<\/tr>\n
$<\/td>\n\u5339\u914d\u4e00\u884c\u672b\u5c3e\u7684\u7a7a\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n
\\b<\/td>\n\u5339\u914d\u4e00\u4e2a\u5355\u8bcd\u524d\u540e\u7684\u7a7a\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n
\\B<\/td>\n\u5339\u914d\u4e00\u4e2a\u5355\u8bcd\u4e2d\u95f4\u7684\u7a7a\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n
\\<<\/td>\n\u5339\u914d\u5355\u8bcd\u524d\u9762\u7684\u7a7a\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n
\\><\/td>\n\u5339\u914d\u5355\u8bcd\u540e\u9762\u7684\u7a7a\u5b57\u7b26\u4e32\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
grep \u548c egrep<\/strong><\/div>\n

egrep \u7b49\u540c\u4e8e<\/p>\n

grep -E<\/pre>\n

\u5b83\u4f1a\u4ee5\u6269\u5c55\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u6a21\u5f0f\u6765\u89e3\u91ca\u6a21\u5f0f\u3002\u4e0b\u9762\u6765\u81ea grep \u7684\u5e2e\u52a9\u9875\uff1a<\/p>\n

\u57fa\u672c\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5143\u5b57\u7b26 ?\u3001+\u3001 {\u3001 |\u3001 ( \u548c ) \u5df2\u7ecf\u5931\u53bb\u4e86\u5b83\u4eec\u539f\u6765\u7684\u610f\u4e49\uff0c\u8981\u4f7f\u7528\u7684\u8bdd\u7528\u53cd\u659c\u7ebf\u7684\u7248\u672c \/?\u3001\/+\u3001\/{\u3001\/|\u3001\/( \u548c \/) \u6765\u4ee3\u66ff\u3002 \u4f20\u7edf\u7684 egrep \u5e76\u4e0d\u652f\u6301 { \u5143\u5b57\u7b26\uff0c\u4e00\u4e9b egrep \u7684\u5b9e\u73b0\u662f\u4ee5 \/{ \u66ff\u4ee3\u7684\uff0c\u6240\u4ee5\u4e00\u4e2a\u53ef\u79fb\u690d\u7684\u811a\u672c\u5e94\u8be5\u907f\u514d\u5728 grep -E \u4f7f\u7528 { \u7b26\u53f7\uff0c\u8981\u5339\u914d\u5b57\u9762\u7684 { \u5e94\u8be5\u4f7f\u7528 [}]\u3002<\/p>\n

GNU grep -E \u8bd5\u56fe\u652f\u6301\u4f20\u7edf\u7684\u7528\u6cd5\uff0c\u5982\u679c { \u51fa\u5728\u5728\u65e0\u6548\u7684\u95f4\u9694\u89c4\u8303\u5b57\u7b26\u4e32\u8fd9\u524d\uff0c\u5b83\u5c31\u4f1a\u5047\u5b9a { \u4e0d\u662f\u7279\u6b8a\u5b57\u7b26\u3002<\/p>\n

\u4f8b\u5982\uff0cgrep -E '{1' \u547d\u4ee4\u641c\u7d22\u5305\u542b {1 \u4e24\u4e2a\u5b57\u7b26\u7684\u4e32\uff0c\u800c\u4e0d\u4f1a\u62a5\u51fa\u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n

POSIX.2 \u6807\u51c6\u5141\u8bb8\u8fd9\u79cd\u64cd\u4f5c\u7684\u6269\u5c55\uff0c\u4f46\u5728\u53ef\u79fb\u690d\u811a\u672c\u6587\u4ef6\u91cc\u5e94\u8be5\u907f\u514d\u8fd9\u6837\u4f7f\u7528\u3002<\/p><\/blockquote>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-6941-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1ahttp:\/\/lrxjmw.cn\/regular-expressions-in-grep.html<\/a>\u7f16\u8f91\uff1a\u90d1\u5e05\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5728 Linux \u3001\u7c7b Unix \u7cfb\u7edf\u4e2d\u6211\u8be5\u5982\u4f55\u4f7f\u7528 Grep \u547d\u4ee4\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u5462\uff1fLinux \u9644\u5e26\u6709 GNU grep \u547d\u4ee4\u5de5\u5177\uff0c\u5b83\u652f\u6301\u6269\u5c55\u6b63\u5219\u8868\u8fbe\u5f0f\uff08extended regular expressions\uff09\uff0c\u800c\u4e14 GNU grep \u5728\u6240\u6709\u7684 Linux \u7cfb\u7edf\u4e2d\u90fd\u662f\u9ed8\u8ba4\u6709\u7684\u3002Grep \u547d\u4ee4\u88ab\u7528\u4e8e\u641c\u7d22\u5b9a\u4f4d\u5b58\u50a8\u5728\u60a8\u670d\u52a1\u5668\u6216\u5de5\u4f5c\u7ad9\u4e0a\u7684\u4efb\u4f55\u4fe1\u606f\u3002<\/p>\n","protected":false},"author":63,"featured_media":79141,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-71979","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/71979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=71979"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/71979\/revisions"}],"predecessor-version":[{"id":79178,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/71979\/revisions\/79178"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/79141"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=71979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=71979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=71979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}