perl -pi.bak -e 's/text/newtext/g' /path/to/file