sed -i -e和sed -ie有什么区别? [英] What is the difference between `sed -i -e` and `sed -ie`?

查看:170
本文介绍了sed -i -e和sed -ie有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sed -i -e sed -ie 有什么区别?从帮助中不是很清楚 sed --help

What is the difference between sed -i -e and sed -ie ? It's not very clear from help sed --help

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

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

In second case it creates some backup file?

一般Unix utils不允许组合标志吗?

In general Unix utils do not permit to combine flags?

只是一个例子来说明正在发生的事情:

Just an example to show what is happening:

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's:bla:blakva:g'1.txt 也可以工作./p>

Also not still sure what is -e doing in my example, because sed -i 's:bla:blakva:g' 1.txt works too.

推荐答案

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

When you give sed -i -e, sed sees two options.

但是,当您提供 sed -ie 时, sed 仅将 -i 选项与后缀视为 e .这就是您使用后缀 e 进行文件备份的原因.

But, When you give sed -ie, sed sees -i option only with suffix as e. That is the reason you got file backup with e suffix.

来自 man sed :

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

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

就地编辑文件(如果提供SUFFIX,则进行备份)

edit files in place (makes backup if SUFFIX supplied)

这篇关于sed -i -e和sed -ie有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆