Sed(Stream EDitor)替换字符串

本文深入解析了sed命令的使用方法,包括其基本语法、参数选项以及实际应用案例。sed,即Stream Editor,是一种强大的文本处理工具,能够实现文本的查找、替换、删除、插入等操作,特别适用于批量修改文件内容。文章重点介绍了如何使用-i选项进行原地编辑,以及s命令的全局替换功能。

sed   -i  's/original/new/g'

详细说明:

  • sed = Stream EDitor(Stream编辑)
  • -i = in-place (i.e. save back to the original file)(回写源被替换文件)
  • The command string:

    • s = the substitute command(替换命令)
    • original = a regular expression describing the word to replace (or just the word itself)(被替换)
    • new = the text to replace it with (替换为)
    • g = global (i.e. replace all and not just the first occurrence) (全部替换)
  • file.txt = the file name

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值