打开/etc/passwd文件取前五行
cat /etc/passwd|head -n 5
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
观察发现每一行都有‘:’每一项之间通过‘:’来分隔,如果想要取第一项可以输入如下命令:
cat /etc/passwd|head -n 5 | cut -d ':' -f 1
root
daemon
bin
sys
sync