[root@localhost ~]# cat /etc/passwd | grep "/bin/bash" | grep "root"
root:x:0:0:root:/root:/bin/bash
[root@localhost ~]# cat /etc/passwd | grep "/bin/bash" | grep -v "root" ------------> grep 加了-v 就是取反的结果
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
root:x:0:0:root:/root:/bin/bash
[root@localhost ~]# cat /etc/passwd | grep "/bin/bash" | grep -v "root" ------------> grep 加了-v 就是取反的结果
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
[root@localhost ~]# cat /etc/passwd | grep "/bin/bash" | grep -v "root" | cut -d ":" -f 1
mysql
比如 你要截取多个
这个表示的意思是 我要截取 第二列和第四列
本文通过几个具体的grep命令示例,展示了如何从Linux系统的/etc/passwd文件中筛选出使用/bin/bash shell的用户,并进一步筛选除root用户外的其他用户。
790

被折叠的 条评论
为什么被折叠?



