There might be a better solution than this but you can use the below command. `sed /hostname.*$/s//"hostname=int1"/g /home/path/of/your/original/file > /tmp/hello.$$` `cat /tmp/hello.$$ > /home/path/of/your/original/file`