sed -e -i “s/hoge/foo/g” index.php

sed command
commands that can replace all strings, extract them on a line by row basis, delete them, and perform various text processing. Process contents can be specified by command line parameters, and batch processing can be done non-interactively.

-e: specify processing content
-i : replace the file without outputting the result.

echo "hoge";
[vagrant@localhost tests]$ ls
index.php  test
[vagrant@localhost tests]$ sed -i -e 's/hoge/foo/g' index.php
[vagrant@localhost tests]$ cat index.php

echo "foo";

すげーーーーーーーーーーーー