linux sed命令

sed:
sed 默认读取整个文件并对其中的每一行进行修改。
1、原文件内容保持不变
2、输出可以被重定向到另一文件中,以保存变化

sed [options] ‘{command}’ [filename]

替换命令:
‘s/{old value}/{new value}/’
e.g.
$ echo The tiger cubs will meet on Tuesday after school | sed
‘s/tiger/wolf/’
The wolf cubs will meet on Tuesday after school

多次修改:
$ echo The tiger cubs will meet on Tuesday after school | sed ’
s/tiger/wolf/; s/after/before/’
The wolf cubs will meet on Tuesday before school

or

$ echo The tiger cubs will meet on Tuesday after school | sed -e ’
s/tiger/wolf/’ -e ‘s/after/before/’
The wolf cubs will meet on Tuesday before school
$

全局处理
$ echo The tiger cubs will meet this Tuesday at the same time
as the meeting last Tuesday | sed ‘s/Tuesday/Thursday**/g**’
The tiger cubs will meet this Thursday at the same time
as the meeting last Thursday
$

来源自网络

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值