perl -pi -e 's/bar/foo/g' myfile