linux输出shell,Linux Shell 输出命令实例

Linux Shell 输出命令实例

发布时间:2009-07-14 00:27:38来源:红联作者:wangyoubang

[root@root 2009521]# cat shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

mma7450 0-001d: reg0x04: 000 0x00

mma7450 0-001d: reg0x05: 000 0x00

mma7450 0-001d: reg0x06: 000 0x00

mma7450 0-001d: reg0x07: 000 0x00

mma7450 0-001d: reg0x08: 000 0x00

mma7450 0-001d: reg0x09: 000 0x00

mma7450 0-001d: reg0x0a: 000 0x00

head命令

[root@root 2009521]# head -n 4 shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

[root@root 2009521]# head -4 shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

诸如此类的命令:tail

grep 的使用

[root@root 2009521]# grep -n 'reg0x0[0-3]' shell

1:mma7450 0-001d: reg0x00: 000 0x00

2:mma7450 0-001d: reg0x01: 000 0x00

3:mma7450 0-001d: reg0x02: 000 0x00

4:mma7450 0-001d: reg0x03: 000 0x00

awk的使用

[root@root 2009521]# awk '/reg0x0[0-3]/' shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

[root@root 2009521]# awk '{if($3~/reg0x0[0-3]:/)print $0;}' shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

[root@root 2009521]# awk '$3=="reg0x03:"{print $0}' shell

mma7450 0-001d: reg0x03: 000 0x00

[root@root 2009521]# awk '$3=="reg0x03:"' shell

mma7450 0-001d: reg0x03: 000 0x00

[root@root 2009521]# awk '{if($3=="reg0x03:")print $0}' shell

mma7450 0-001d: reg0x03: 000 0x00

sed的使用

[root@root 2009521]# sed -n '1,4p' shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

[root@root 2009521]# sed -n '1,$p' shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

mma7450 0-001d: reg0x04: 000 0x00

mma7450 0-001d: reg0x05: 000 0x00

mma7450 0-001d: reg0x06: 000 0x00

mma7450 0-001d: reg0x07: 000 0x00

mma7450 0-001d: reg0x08: 000 0x00

mma7450 0-001d: reg0x09: 000 0x00

mma7450 0-001d: reg0x0a: 000 0x00

[root@root 2009521]# sed -n "1,4p" shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

[root@root 2009521]# sed -n "1,\$p" shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

mma7450 0-001d: reg0x04: 000 0x00

mma7450 0-001d: reg0x05: 000 0x00

mma7450 0-001d: reg0x06: 000 0x00

mma7450 0-001d: reg0x07: 000 0x00

mma7450 0-001d: reg0x08: 000 0x00

mma7450 0-001d: reg0x09: 000 0x00

mma7450 0-001d: reg0x0a: 000 0x00

[root@root 2009521]# sed -n '/reg0x0[0-3]:/p' shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

[root@root 2009521]# sed -n "/reg0x0[0-3]:/p" shell

mma7450 0-001d: reg0x00: 000 0x00

mma7450 0-001d: reg0x01: 000 0x00

mma7450 0-001d: reg0x02: 000 0x00

mma7450 0-001d: reg0x03: 000 0x00

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值