bash grep newline

后端 未结 11 1828
渐次进展
渐次进展 2021-01-04 12:38

[Editorial insertion: Possible duplicate of the same poster\'s earlier question?]

Hi, I need to extract from the file:

first
second
         


        
11条回答
  •  半阙折子戏
    2021-01-04 13:06

    I don't really understand what do you want to match. I would not use grep, but one of the following:

    tail -2 file         # to get last two lines
    head -n +2 file      # to get all but first line
    sed -e '2,3p;d' file # to get lines from second to third
    

    (not sure how standard it is, it works in GNU tools for sure)

提交回复
热议问题