awk输出匹配行的前一行,后一行的方法
引用请注明出处: https://seonoco.com/blog/awk-output-matching-line-of-the-previous-line-after-a-line-of-method
发布于 分类 Linux
awk输出匹配行的前一行,后一行的方法
# cat test
1
a
2
a
3
4
a
5
6
7
8
a
9
提取a前面一列
# cat test|awk '/a/{print a;}{a=$0}'
1
2
4
8
# cat test|awk '/a/{getline;print}'
2
3
5
9
-- The End --