• 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 ~]#

  • 相关阅读:
    Linux netstat 命令入门知识
    Linux文件预读对系统的影响
    Ubuntu下配置Hadoop环境
    Debian Wheezy 安装Nginx+HHVM
    Linux Glibc库严重安全漏洞检测与修复方案
    关于系统时间的几个问题
    C语言的整型溢出问题
    Django Nginx配置
    linux上安装mysql5.7
    日期、时间选择器
  • 原文地址:https://www.cnblogs.com/xusx/p/6093406.html
Copyright © 2020-2023  润新知