One way using [tag:sed]: ``` sed -e '/^>/ { N; }; /Sequence unavailable/ { d; }' file.fa ``` For each header line, append the next line of input into the pattern space. Then, if the record contains "Sequence unavailable" delete the pattern space and start a new cycle. ---------- Or using [tag:awk]: ``` awk '/^>/ { f=$0; next } /^Sequence unavailable/ { next } f { print f; f="" }1' file.fa ``` For each header line, use a variable to store the current record. We can use [_next_](https://www.gnu.org/software/gawk/manual/html_node/Next-Statement.html) here to force awk to immediately stop processing the current record and move on to the next record, which is just the next line, since, by default, awk's [_record separator_](https://www.gnu.org/software/gawk/manual/html_node/awk-split-records.html) is a newline character. Then, stop processing the current record and move on to the next record if that line begins with "Sequence unavailable". Finally, print the header line if it exists and unset the variable that we used to store it if it does. Once we've printed the header, we can then just print the current record. We can do this by appending _1_ to our command string. The _1_ on the end just returns true, and by doing so, it performs the default action, which is to print the current record.