Bootstrap

练习六:grep练习(一)

一、练习

    1.显示/etc/passwd文件中不以/bin/bash结尾的行?

[root@wybaron_host1015 ~]# grep -v "/bin/bash$" /etc/passwd

    2.显示/proc/meminfo文件中以大小s开头的行(要求:使用两种方式)?

[root@wybaron_host1015 ~]# grep -i "^s" /proc/meminfo
[root@wybaron_host1015 ~]# grep "^[sS]" /proc/meminfo

    3.显示/etc/passwd文件中ID号最大的用户的用户名?

[root@wybaron_host1015 ~]# cat /etc/passwd | sort -n -t ':' -k 3 | tail -n 1 | cut -d: -f1 

    4.如果用户root存在,显示其默认的shell程序?

[root@wybaron_host1015 ~]# id root &> /dev/null &&a
;