shell脚本截取列cut的使用

来源:互联网 发布:mysql的事务隔离级别 编辑:程序博客网 时间:2024/05/22 06:56
[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@localhost ~]# cat /etc/passwd |  grep "/bin/bash" | grep -v  "root" | cut -d ":" -f 1
mysql

比如 你要截取多个

这个表示的意思是  我要截取 第二列和第四列