标签:linux学习
方法1:sed
[root@ZHOUQIZHONG ~]# stat /etc/hosts | sed -nr‘4s#.*\(0|/-.*##gp‘
644
[root@ZHOUQIZHONG ~]#
方法2:sed 反向引用
[root@ZHOUQIZHONG tmp]# stat /etc/hosts |sed -nr ‘4s#.*\(0(.*)\/-.*#\1#gp‘
644
[root@ZHOUQIZHONG tmp]#
方法3:awk
[root@ZHOUQIZHONG ~]# stat /etc/hosts |awk -F‘[/0]‘ ‘NR==4{print $2}‘
644
[root@ZHOUQIZHONG ~]#
方法4:stat
[root@ZHOUQIZHONG ~]# stat -c%a /etc/hosts
644
[root@ZHOUQIZHONG ~]#
>>>>>>>>刚学的这些方法,方法还有很多,linux魅力无穷啊<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
本文出自 “qizhong” 博客,请务必保留此出处http://qizhong.blog.51cto.com/12933988/1953445
标签:linux学习
原文地址:http://qizhong.blog.51cto.com/12933988/1953445