#1、显示/proc/meminfo文件中以大小s开头的行(要求:使用两种方法)
cat /proc/meminfo |grep -i “^s”
cat /proc/meminfo |grep “^(s|S)”
[root@localhost /]# cat /proc/meminfo | grep -i "^s"
SwapCached: 0 kB
SwapTotal: 3145724 kB
SwapFree: 3145724 kB
[root@localhost /]# cat /proc/meminfo | grep "^\(s\|S\)"
SwapCached: 0 kB
SwapTotal: 3145724 kB
SwapFree: 3145724 kB
#2、显示/etc/passwd文件中不以/bin/bash结尾的行
[root@localhost /]# cat /etc/passwd | grep -v "/bin/bash$"
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
#3、显示用户rpc默认的shell程序
[root@localhost /]# cat /etc/passwd | grep "^rpc" | cut -d ":" -f7
/bin/bash