首页 > 系统服务 > 详细

linux shell(1) awk&cut

时间:2015-03-22 14:51:00      阅读:155      评论:0      收藏:0      [点我收藏+]
#!/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

 

linux shell(1) awk&cut

原文:http://www.cnblogs.com/stsjiayou/p/4357221.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!