How can I print a matching line, one line immediately above it and one line immediately below?

后端 未结 8 1082
你的背包
你的背包 2020-12-16 07:23

From a related question asked by Bi, I\'ve learnt how to print a matching line together with the line immediately below it. The code looks really simple:

#!p         


        
8条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 08:01

    It will probably be easier just to use grep for this as it allows printing of lines before and after a match. Use -B and -A to print context before and after the match respectively. See http://ss64.com/bash/grep.html

提交回复
热议问题