sed -i -e 's/yourpattern/yourpatternXXXTTTXXX/g' -i -e 's/XXXTTTXXX/ /g' file ^add some unique pattern here # -i update the file , try without -i