If you do not want to print a consistent line (or any of the following lines):
sed -n '/The second line/q;p' inputfile
This suggests that "when you reach the line that matches the pattern, close, otherwise print each line." The -n prevents implicit printing, and p requires explicitly printing lines.
or
sed '/The second line/,$d' inputfile
This says: "Remove all lines from the output starting with the matching line and continue to the end of the file."
but the first is faster.
If you want to print a consistent line, but not the following lines:
sed '/The second line/q' inputfile
This means that "print all lines and exit when the matching line is reached" (the -n option (without implicit printing) is not used).
See man sed for more information.
Dennis Williamson Mar 08 2018-11-11T00: 00Z
source share