3 回答

TA貢獻(xiàn)2041條經(jīng)驗(yàn) 獲得超4個(gè)贊
awk 'f{print;f=0} /regexp/{f=1}' file
awk 'c&&!--c; /regexp/{c=1}' file
awk '/regexp/{f=1}f' file
awk 'f;/regexp/{f=1}' file
awk 'c&&!--c;/regexp/{c=N}' file
awk 'c&&!--c{next}/regexp/{c=N}1' file
awk 'c&&c--;/regexp/{c=N}' file
awk 'c&&c--{next}/regexp/{c=N}1' file
awk '/regexp/{c=N}c&&c--' file

TA貢獻(xiàn)2065條經(jīng)驗(yàn) 獲得超14個(gè)贊
sed -n '/ABC/{n;p}' infile
-A NUM, Print NUM lines of trailing context after matching lines.
foo bar baz bash bongo
$ grep -A 1 "bar" file bar baz $ sed -n '/bar/{n;p}' file baz

TA貢獻(xiàn)1826條經(jīng)驗(yàn) 獲得超6個(gè)贊
sed -n '/pattern/,$p' # prints all lines after ( and including ) the pattern
sed -n '/pattern/,$p' | tail -n+2 # all lines after first occurrence of pattern
head -1
sed -n '/pattern/,$p' | tail -n+2 | head -1 # prints line after pattern
添加回答
舉報(bào)