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

 

posted @ 2015-03-22 13:34  风动水韵  阅读(213)  评论(0编辑  收藏  举报