您的位置:首页 > 运维架构 > Shell

shell脚本截取列cut的使用

2017-08-17 10:22 82 查看
[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



比如 你要截取多个



这个表示的意思是  我要截取 第二列和第四列  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: