在Shell脚本中查找并替换 [英] Find and replace in shell scripting
本文介绍了在Shell脚本中查找并替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用shell搜索文件然后替换值?当我安装服务时,我希望能够在配置文件中搜索一个变量,然后在该值中替换/插入我自己的设置.
Is it possible to search in a file using shell and then replace a value? When I install a service I would like to be able to search out a variable in a config file and then replace/insert my own settings in that value.
推荐答案
当然,您可以使用sed或awk进行此操作. sed示例:
Sure, you can do this using sed or awk. sed example:
sed -i 's/Andrew/James/g' /home/oleksandr/names.txt
这篇关于在Shell脚本中查找并替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文