perl -ne 'BEGIN{ $s=q ~(.*)$/'"'"',$lines,$matches) 10.(.*)$/'"'"',$lines,$matches) (.*)$/'"'"',$lines,$matches)~};print unless /\Q$s\E/' input.txt #### perl -ne 'print unless m~\Q(.*)\E\$/'"'"',\$lines,\$matches\Q) 10.(.*)\E\$/'"'"',\$lines,\$matches\Q) (.*)\E\$/'"'"',\$lines,\$matches\)~x' input.txt