方法一
[root@localhost httpd]# sed -n '6p' /etc/inittab
#
方法二 先输出前六行用管道传过去接着取出第六行
[hadoop@localhost ~]$ head -6 /etc/inittab | tail -1
#
2、如果用户hadoop不存在就添加,否则显示用户已存在
[root@localhost ~]# id hadoop >& /dev/null && echo "The user already exists." || useradd hadoop
[root@localhost ~]# id hadoop >& /dev/null && echo "The user already exists." || useradd hadoop
The user already exists.
[root@localhost ~]# su - hadoop
welcome my server!