Linux 第三次练习(文本处理工具练习)

时间:2021-09-21 12:06:42   收藏:0   阅读:20
1、找出ifconfig“网卡名”命令结果中本机的IPv4地址
ifconfig| egrep -A1 ^eth0 | tail -n+2 | tr -s " " | cut -d" " -f 3

2、查出分区空间使用率的最大百分比值

df | tail -n+2 | tr -s " " % | cut -d"%" -f5 | sort -nr | head -n+1

3、查出用户UID最大值的用户名、UID及shell类型

cat /etc/passwd | cut -d":" -f1,3,7 | sort -t: -k2 -nr | head -n+1

4、查出/tmp的权限,以数字方式显示

stat  /tmp |head -n4|tail -n1 |cut -d"/" -f1 | cut -d"(" -f2

5、统计当前连接本机的每个远程主机IP的连接数,并按从大到小排序

ss -nt | tail -n+2 | tr -s " " : | cut -d":" -f6 | sort -n |uniq -c | sort -nr

原文:https://www.cnblogs.com/chen21/p/15311350.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!