使用命令行更改所有内容
我想知道是否有一种方法可以使用命令行更改 /www/ 目录中所有文件中的特定单词。只是寻找一种更快的方法来更改特定单词,这样我就不需要手动打开所有文件!谢谢!
I'm wondering if there is a way to change a specific word in all of the files within the /www/ directory using command line. Just looking for a faster way to change out a specific word so I don't need to open all the files manually! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
find /www -type f -exec sed -i 's/foo/bar/g' \{\} \;
每次 foo 出现在
中的任何文件中时,此行都会将 foo 替换为 bar >/www
。在运行之前,请务必确保您知道/www
下有什么以及替换后会对这些文件执行什么操作。find /www -type f -exec sed -i 's/foo/bar/g' \{\} \;
This line will replace foo with bar every time foo occurs in any file in
/www
. Be very sure you know what's under/www
and what the replacement would do to those files before running it.您可能正在寻找 grep-sed 解决方案来查找并替换,如果您使用的是 Mac(并指 Mac 的终端应用程序)。
You might be looking for a grep-sed solution to find and replace, if you are on a Mac (and referring to the Mac's Terminal app).