wyyy721 发表于 2018-8-27 12:22:17

while示例_shell脚本

  工作环境:Red Hat Enterprise Linux Server>  #!/bin/bash
  #
  awk -F: '{print $1,$3,$7}' /etc/passwd >>passwd.txt

  while read name>  do
  echo "user name:$name"
  echo "user uid :$id"
  echo "user shell:$shell"
  echo
  done < passwd.txt
  注意:passwd.txt文件的列数一定要大于变量的个数,否则,会报错

页: [1]
查看完整版本: while示例_shell脚本