linux looks at the methods before and after the matched content

  • 2020-11-18 06:36:17
  • OfStack

In THE linux system, grep is used to print the matching upper and lower lines

grep can be implemented if you just want to match the pattern up and down a few lines.

Search for the line number of content in inputfile that satisfies parttern

[

grep -n 'parttern' inputfile

]

View the contents of a file inputfile after the line number (90) specified

[

$grep-5 'parttern' inputfile // Prints 5 lines before and 5 lines after the matching line

$ES28en-ES29en 5 'parttern' inputfile // Prints 5 lines before and 5 lines after the matching line

$ES35en-ES36en 5 'parttern' inputfile // Prints 5 lines after matching

$ES42en-ES43en 5 'parttern' inputfile // Prints the first 5 lines of the matching line

][

tail -n +90 inputfile

]

View lines 190 to 196 of the file inputfile

[

sed -n '114,196p' inputfile

]

Related articles: