zoukankan      html  css  js  c++  java
  • stat /etc/hosts 取行取列644

    [root@xusx ~]# stat /etc/hosts
      File: `/etc/hosts'
      Size: 183        Blocks: 8          IO Block: 4096   regular file
    Device: 802h/2050d Inode: 128037      Links: 2
    Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: 2016-11-30 17:27:01.196998563 +0800
    Modify: 2016-11-30 17:22:54.530989179 +0800
    Change: 2016-11-30 17:22:54.608997694 +0800

    第一种

    [root@xusx ~]# stat /etc/hosts |awk -F "[0/]+" 'NR==4{print $2}'
    644
    [root@xusx ~]# stat /etc/hosts|sed -n '4p'|sed -r 's#(^.*(0)|(/-.*)$##g'  =====>加括号
    644

    [root@xusx ~]# stat /etc/hosts|sed -rn '4s#^.*(0|/-.*$##gp'
    644

    [root@xusx ~]# stat /etc/hosts|sed -rn '4s#(^.*(0)|(/-.*$)##gp'
    644

    第二种

    [root@xusx ~]# stat /etc/hosts|sed -rn '4s#^.*(0(.*)/-.*$#1#gp'   ====>后向引用()--->1
    644

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    第三种

    [root@xusx ~]# stat /etc/hosts |awk -F "[0/]" 'NR==4{print $2}'  ======>[0/]+  ---->1次到多次
    644

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    第四种

    [root@xusx ~]# stat -c %a /etc/hosts
    644

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    第五种

    [root@xusx ~]# stat /etc/hosts|sed -n '4p'
    Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
    [root@xusx ~]# stat /etc/hosts|sed -n '4p'|cut -d "/" -f1   ===>一次只能切一个字符
    Access: (0644
    [root@xusx ~]# stat /etc/hosts|sed -n '4p'|cut -d "/" -f1|cut -d "0" -f2
    644

    -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    第六种

    [root@xusx ~]# stat /etc/hosts|grep 'Uid'|grep -o [1-9]*
    644
    [root@xusx ~]#

  • 相关阅读:
    JavaSE Day11
    JavaSE Day10
    JavaSE Day9
    JavaSE Day8
    JavaSE Day7
    a
    js 操作 字符串
    委托的生明与使用
    T-SQL 的简单查询语句
    asp.net服务控件的生命周期
  • 原文地址:https://www.cnblogs.com/xusx/p/6093406.html
Copyright © 2011-2022 走看看