文件内容的显示思维导图
2、文件内容查看:
(1)查看/etc/passwd文件的第6行
[root@zl test]# cat /etc/passwd | head -6 | tail -1
sync:x:5:0:sync:/sbin:/bin/sync
(2)查看/etc/selinux/config 以 SELINUX开头的行
[root@zl test]# grep ^SELINUX /etc/selinux/config
(3)查找/etc/ssh/sshd_config 以no结尾的行
grep no$ /etc/ssh/sshd_config
(4)过滤/etc/ssh/sshd_config 包含数字的行
grep -v [0-9] /etc/ssh/sshd_config
3、文本处理命令:
(1)查看/etc/passwd文件以 : 为分隔符的第一列内容,并按字母逆序排序
cut -d : -f 1 /etc/passwd | sort -r
(2)使用cut命令将当前主机的ip地址切割显示
[root@bogon ~]# ip address | head -12 | tail -6 | grep inet | tr 'inet' ' ' | cut -d / -f 1 | head -1