一、基础部分:
1.1 找出/proc/meminfo文件中,所有以大小或小写s开头的行,至少三种方式
[root@localhost ~]# grep - i '\<s' /proc/meminfo
[root@localhost ~]# grep - i '^s' /proc/meminfo
[root@localhost ~]# grep '^[sS]' /proc/meminfo
[root@localhost ~]# grep '\<[sS]' /proc/meminfo
[root@localhost ~]# grep -E '^s|^S' /proc/meminfo
[root@localhost ~]# grep '^s\|^S' /proc/meminfo
1.2 显示当前系统上root,centos或者user1用户的相关信息
[root@localhost ~]# grep "^\ ( root \| centos \| user1 \ ) \b" /etc/passwd
[root@localhost ~]# grep - E "^(root|centos|user1)\b" /etc/passwd
1.3 找出/etc/rc.d/init.d/functions文件中某单词后面跟一个小括号的行
[root@localhost ~]# grep -n -P ".*(\w)\(\)" /etc/rc.d/init.d/f