sed -e 's#< [^>]*>##g' < index.php > index.txt Another way of doing it: sed 's/< [^>]*>//g' < index.php > index.txt