{"id":191907,"date":"2020-05-19T14:47:17","date_gmt":"2020-05-19T06:47:17","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=191907"},"modified":"2020-05-19T14:47:17","modified_gmt":"2020-05-19T06:47:17","slug":"grep-search-multiple-str","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/grep-search-multiple-str.html","title":{"rendered":"\u4f7f\u7528grep\u641c\u7d22\u591a\u4e2a\u5b57\u7b26\u4e32"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n grep\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u5728\u4e00\u4e2a\u6216\u591a\u4e2a\u6587\u4ef6\u4e2d\u641c\u7d22\u4e0e\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u7684\u884c\uff0c\u5e76\u5c06\u5339\u914d\u7684\u7ed3\u679c\u5199\u5165\u6807\u51c6\u8f93\u51fa\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Grep\u7684\u591a\u6761\u4ef6\u641c\u7d22\u6a21\u5f0f<\/strong><\/div>\n

grep\u652f\u6301\u4e09\u79cd\u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\uff1aBasic\u3001Extended\u548cPerl\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u5f53\u6ca1\u6709\u6307\u5b9a\u6b63\u5219\u8868\u8fbe\u5f0f\u7c7b\u578b\u65f6\uff0cgrep\u5c06\u641c\u7d22\u6a21\u5f0f\u89e3\u91ca\u4e3aBasic\u57fa\u672c\u6b63\u5219\u8868\u8fbe\u5f0f\u3002<\/p>\n

\u4f7f\u7528\u591a\u6761\u4ef6\u641c\u7d22\u6a21\u5f0f\u65f6\uff0c\u8bf7\u4f7f\u7528|<\/code>\u7ba1\u9053\u7b26\u3002\u4f7f\u7528grep\u7684\u57fa\u672c\u6b63\u5219\u8868\u8fbe\u5f0f\u641c\u7d22\u591a\u4e2a\u6761\u4ef6\uff0c\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n

\r\n]# grep 'pattern1\\|pattern2' file\r\n<\/pre>\n

\u5f53\u4f7f\u7528\u57fa\u672c\u6b63\u5219\u8868\u8fbe\u5f0f\u65f6\uff0c\u9700\u8981\u4f7f\u7528\\<\/code>\u8f6c\u4e49\u7b26\u4e3a|<\/code>\u7ba1\u9053\u7b26\u8f6c\u4e49\u3002<\/p>\n

\u5982\u679c\u4f7f\u7528\u6269\u5c55\u6a21\u5f0f\uff0c\u53ef\u4ee5\u6dfb\u52a0-E<\/code>\u53c2\u6570\u3002\u4f7f\u7528\u6269\u5c55\u6a21\u5f0f\uff0c\u5c31\u4e0d\u9700\u8981\u4e3a|<\/code>\u7ba1\u9053\u7b26\u6dfb\u52a0\u8f6c\u4e49\u7b26\u4e86\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528egrep<\/code>\u547d\u4ee4\uff0c\u8fd9\u4e2a\u547d\u4ee4\u548cgrep -E<\/code>\u7528\u6cd5\u4e00\u6837\u3002<\/p>\n

\r\n]# grep 'pattern1|pattern2' file\r\n]# egrep 'pattern1|pattern2' file\r\n<\/pre>\n
\u4f7f\u7528\u5b9e\u4f8b<\/strong><\/div>\n

\u68c0\u67e5\u64cd\u4f5c\u7cfb\u7edf\u662f\u5426\u5f00\u542f\u865a\u62df\u5316\u529f\u80fd\uff0c\u4f7f\u7528Basic\u57fa\u672c\u6a21\u5f0f\uff1a<\/p>\n

\r\n[root@localhost ~]# grep 'vmx\\|svm' \/proc\/cpuinfo \r\nflags\t\t: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec arat spec_ctrl intel_stibp flush_l1d arch_capabilities\r\n<\/pre>\n

\"\"
\n\u4f7f\u7528\u6269\u5c55\u6a21\u5f0f\u5c31\u4e0d\u9700\u8981\u6dfb\u52a0\\<\/code>\u8f6c\u4e49\u7b26\u4e86\uff0c\u6269\u5c55\u6a21\u5f0f\u4f7f\u7528\u65b9\u5f0f\uff1a<\/p>\n

\r\n[root@localhost ~]# grep -E 'vmx|svm' \/proc\/cpuinfo \r\nflags\t\t: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec arat spec_ctrl intel_stibp flush_l1d arch_capabilities\r\n\r\n# \u6216\u8005\r\n\r\n[root@localhost ~]# egrep 'vmx|svm' \/proc\/cpuinfo \r\nflags\t\t: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec arat spec_ctrl intel_stibp flush_l1d arch_capabilities\r\n<\/pre>\n

\"\"
\n\u9ed8\u8ba4\u60c5\u51b5grep\u533a\u5206\u5927\u5c0f\u5199\uff0c\u5982\u679c\u9700\u8981\u5ffd\u7565\u5927\u5c0f\u5199\uff0c\u53ef\u4ee5\u6dfb\u52a0-i<\/code>\u53c2\u6570\uff1a<\/p>\n

\r\n[root@localhost ~]# grep -E -i 'VMX|SVM' \/proc\/cpuinfo \r\nflags\t\t: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec arat spec_ctrl intel_stibp flush_l1d arch_capabilities\r\n\r\n# \u6216\u8005\r\n\r\n[root@localhost ~]# egrep -i 'VMX|SVM' \/proc\/cpuinfo \r\nflags\t\t: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec arat spec_ctrl intel_stibp flush_l1d arch_capabilities\r\n<\/pre>\n

\"\"<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

grep\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u5728\u4e00\u4e2a\u6216\u591a\u4e2a\u6587\u4ef6\u4e2d\u641c\u7d22\u4e0e\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u7684\u884c\uff0c\u5e76\u5c06\u5339\u914d\u7684\u7ed3\u679c\u5199\u5165\u6807\u51c6\u8f93\u51fa\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

grep\u652f\u6301\u4e09\u79cd\u6b63\u5219\u8868\u8fbe\u5f0f\u8bed\u6cd5\uff1aBasic\u3001Extended\u548cPerl\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u5f53\u6ca1\u6709\u6307\u5b9a\u6b63\u5219\u8868\u8fbe\u5f0f\u7c7b\u578b\u65f6\uff0c […]<\/p>\n","protected":false},"author":362,"featured_media":191908,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-191907","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\/191907","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\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=191907"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/191907\/revisions"}],"predecessor-version":[{"id":191913,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/191907\/revisions\/191913"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/191908"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=191907"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=191907"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=191907"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}