while示例_shell脚本
工作环境:Red Hat Enterprise Linux Server release 6.5 (Santiago) 、 bash
#!/bin/bash
#
awk -F: '{print $1,$3,$7}' /etc/passwd >>passwd.txt
while read name id shell
do
echo "user name:$name"
echo "user uid :$id"
echo "user shell:$shell"
echo
done < passwd.txt
注意:passwd.txt文件的列数一定要大于变量的个数,否则,会报错
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。