sed 使用

1,基本结构

sed [option] {cmd} {input_file}

sed -n 'p' test.log

2,sed执行基本过程

read -> execute -> print -> repeat

3,在每一行执行多个命令,答应以name和test开头的行

sed -n -e '/^name/p' -e '/^test/p' test.log

4,打印  p, 拟制打印 n

5,删除  d

6,替换  s

sed  ‘/pattarn/s/old/new/[flag]’ input_file

sed '/test/s/old/new/' input //substitute the first old to new, like vim

sed '/test/s/old/new/g' input //substitute all the old to new, like vim

7, g标志

8,数字标志(1,2,3),只替换第n次出现的地方。

sed '/test/s/old/new/2' input //substitute the second old to new

9,


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值