sed up to first match code example Example: sed up to first match sed '/[match]/q' file.txt #Include q option at the end to grep untilmatch only