加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – `sed -i -e`和`sed -ie`有什么区别?

发布时间:2020-12-15 21:55:37 所属栏目:安全 来源:网络整理
导读:sed -i -e和sed -ie有什么区别? 从帮助来看并不是很清楚 sed –help -e script,--expression=script add the script to the commands to be executed 在第二种情况下,它创建一些备份文件? 一般来说,Unix utils不允许组合标志? 只是一个展示正在发生的事情
sed -i -e和sed -ie有什么区别?
从帮助来看并不是很清楚
sed –help

-e script,--expression=script
                 add the script to the commands to be executed

在第二种情况下,它创建一些备份文件?

一般来说,Unix utils不允许组合标志?

只是一个展示正在发生的事情的例子:

echo "bla" > 1.txt
cat 1.txt
bla
sed -i -e 's:bla:blakva:g' 1.txt
cat 1.txt
blakva
sed -ie 's:bla:blakva:g' 1.txt
cat 1.txt
blakvakva
*Note: also 1.txte is created,containing
cat 1.txte
blakva

还不能确定-e在我的例子中做什么,因为sed -i的:bla:blakva:g’1.txt也可以.

解决方法

当你给sed -i -e时,sed会看到两个选项.

但是,当你给sed -ie时,sed只看到-i选项,后缀为e.这就是你用e后缀获得文件备份的原因.

From man sed:

-i[SUFFIX],–in-place[=SUFFIX]

edit files in place (makes backup if SUFFIX supplied)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读