I'm a beginner of bash.
Suppose I have a text file sample.txt
, which contains
mercury
venus
earth
mars
jupiter
saturn
uranus
neptune
pluto
and two keywords earth
and saturn
.
The gold is to find the lines that contain the keywords (there is exactly one line that contains each of the keywords), and output all the lines in between, including both keywords lines.
Given the above keywords earth
, saturn
and input, the expected output is
earth
mars
jupiter
saturn
If possible, avoid regex. Is there anyway to do this?