sed提供了-i选项可以“就地”(in-place)修改原始文件。

-i extension
Edit files in-place, saving backups with the specified extension. If a zero-length extension is given, no backup will be saved. It is not recommended
to give a zero-length extension when in-place editing files, as you risk corruption or partial content in situations where disk space is exhausted, etc.

sed -i .bak -e 's/foo/bar/' pom.xml # 备份原始文件
sed -i '' -e 's/foo/bar/' pom.xml   # 不做备份
# sed -i -e 's/foo/bar/' pom.xml    # OS X下有“bug”,会生成名为pom.xml-e的备份文件