linux shell(1) awk&cut

#!/bin/bash
#  Programe:
#      Write a shell, Take the first column from the file in the path of "/etc/passwd". In addition,
#      every column should be showned by a series of string,like [The 1 account is "root"]. The 1 represent the columns
#  History:
#      2015/03/20
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

#sudo awk -F : {printf("The %2d acount is %s\n",NR,$1)} /etc/passwd

accounts=$(sudo cat /etc/passwd | cut -d: -f 1)
for account in $accounts
do
declare -i i=$i+1
echo "The $i account is \"$account\""
done

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。