shell脚本截取列cut的使用
[[email protected] ~]# cat /etc/passwd | grep "/bin/bash" | grep "root"
root:x:0:0:root:/root:/bin/bash
[[email protected] ~]# 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
[[email protected] ~]# cat /etc/passwd | grep "/bin/bash" | grep -v "root" ------------> grep 加了-v 就是取反的结果
mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash
[[email protected] ~]# cat /etc/passwd | grep "/bin/bash" | grep -v "root" | cut -d ":" -f 1
mysql
比如 你要截取多个
这个表示的意思是 我要截取 第二列和第四列