1.查看/etc/passwd文件的第6行
[root@localhost ~]# cat /etc/passwd | head -6 |tail -n -1
2.查看/etc/selinux/config以SELINUX开头的行
[root@localhost ~]# cat /etc/selinux/config | grep ^SELINUX
3.查看/etc/ssh/sshed_config以no结尾的行
[root@localhost ~]# cat /etc/ssh/sshd_config | grep -w no$
4.过滤/etc/ssh/sshd_config 含有数字的行
[root@localhost ~]# cat /etc/ssh/sshed_config |[0-9]
二:文本处理
查看/etc/passwd文件以“:”为分隔符的第一列内容,并按字母逆序排排序写入/username文件。统计/etc/passwd文件一共有几行,只把行数显示
[root@localhost ~]# cat /etc/passwd |cut -d : -f 1 |sort -rn |tee /etc/username
3.统计系统执行频率最高的前十个命令
[root@localhost ~]# history |tr -s " " " " |cut -d " " -f 3 | sort |uniq -c |sort -n |tail -10|tr -s " " " " |cut -d " " -f 3