Linux sanjianke

1. Matching Multiple Lines

awk '/from/,/to/' file
sed -n '/from/,/to/p' file
pcre2grep -M 'from(n|.)to' file
pcre2grep -M '(?s)from.
to' file
grep -Pz '(?s)from.n.to' test

egrep '(A|B)' file
sed -n '/A|B/p' file
sed -n -e '/A/p' -e '/B/p' file

awk '/A|B/{print $0}' file
awk '/A/||/B/{print $0}' file

grep A file | grep B
egrep '(A.B|B.A)' file

Both conditions are true at the same time

sed -n '/A/{/B/p}' file
awk '/A/&&/B/{print $0}' file
awk '$0~/A/&&/B/{print $0}' file

All three conditions hold true

awk '/A/&&/B/&&/C/{print $0}' file
awk '$0~/A/&&/B/&&/C/' file
sed -n '/A/{/B/,/C/p}' file

posted @ 2023-10-31 15:28  LIANG2023  阅读(3)  评论(0)    收藏  举报