#!/bin/bash cd /tmp || { echo "Unable to cd to /tmp ... Exiting" && exit 1; } echo $'a\nb\nc\nphp\nhtml\nomg' > ./tempfile ed - ./tempfile <<< $'v/\(php\|html\)/d\nw\nq' cat ./tempfile rm ./tempfile