← Back to all posts

Learning more sed

Published on 2026-06-04

Want to print all lines from a file until a certain pattern matches?

sed '/pattern/q' FILENAME

It just means when you see this pattern print that line and quit q.

Want to skip all lines in a file until a certain pattern matches?

sed -n '/pattern/,$p'

It just means it will turn off auto print -n and then when you see the pattern take the range of the current line until the end of the input ,$ and print it p.