没有备份文件的 SED [英] SED without backup file

查看:38
本文介绍了没有备份文件的 SED的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下 sed 命令替换文件中的文本:

I use the following sed command to replace text in the file:

sed -i -e 's/noreply@(.*).example.com/noreply@example.com/' cron.yaml

但它会创建文件 cron.yaml 的备份,名称为 cron.yaml-e.

But it create backup of the file cron.yaml under name cron.yaml-e.

我试图将 -i 移到最后:

I tried to move -i to the end:

sed -e 's/noreply@(.*).example.com/noreply@example.com/' -i cron.yaml

但在这种情况下 sed 返回错误.

but in this case sed returns an error.

我应该如何修改我的命令行以避免创建备份文件?

How should I modify my command line to avoid backup file creation?

推荐答案

根据手册页 你应该在 macOS 上指定一个零长度扩展

According to the man page you should specify a zero length extension on macOS

sed -i '' -e 's/noreply@(.*).example.com/noreply@example.com/' 

这篇关于没有备份文件的 SED的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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