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

  • 相关阅读:
    vue项目中使用定时器,离开页面时清除定时器
    不能在循环中使用res.send(err);
    React使用require加载图片失败
    实验五 单元测试
    实验四 代码评审
    UML 建模工具的安装与使用
    结对编程 第二阶段
    结对编程
    GIT 代码版本管理
    结构化方法与面向对象化方法的比较
  • 原文地址:https://www.cnblogs.com/xusx/p/6093406.html
Copyright © 2011-2022 走看看