17维客“一起快乐” >>所属分类 >> shell   

Linux Shell 输出命令实例 编辑词条 发表评论(0)

[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

附件列表


→如果您认为本词条还有待完善,请 编辑词条

上一篇用Shell脚本获取CPU拓扑关系下一篇Linux Shell输出命令实例

词条内容仅供参考,如果您需要解决具体问题
(尤其在法律、医学等领域),建议您咨询相关领域专业人士。
0

收藏到: Favorites  

词条信息

whelk1
whelk1
书童
词条创建者 发短消息   

相关词条