# 1.依次展示/etc/passwd中的用户名和UID。格式如:Hello,$USER,your UID is $UID.

# 2.统计一个有多少个用户

#!/bin/bash
#Program Description:
#Author: Created by ctu_lzq
#Date: //
FILE="/etc/passwd"
LINES=`cat $FILE |wc -l`
#for i in `seq $LINES`;
for ((i=;i<=$LINES;i++));
do
userlist=`sed -n "$i""p" $FILE|awk -F: '{print $1}'`
uidlist=`sed -n "$i""p" $FILE|awk -F: '{print $3}'`
echo "Hello,$userlist,your UID is $uidlist"
done
echo "there are $LINES users"
结果如:
[root@study learnshell]# bash test.sh
Hello,root,your UID is 0
Hello,bin,your UID is 1
Hello,daemon,your UID is 2
Hello,adm,your UID is 3
Hello,lp,your UID is 4
Hello,sync,your UID is 5
Hello,shutdown,your UID is 6
Hello,halt,your UID is 7
Hello,mail,your UID is 8
Hello,uucp,your UID is 10
Hello,operator,your UID is 11
Hello,games,your UID is 12
Hello,gopher,your UID is 13
Hello,ftp,your UID is 14
Hello,nobody,your UID is 99
Hello,dbus,your UID is 81
Hello,usbmuxd,your UID is 113
Hello,rpc,your UID is 32
Hello,rtkit,your UID is 499
Hello,avahi-autoipd,your UID is 170
Hello,vcsa,your UID is 69
Hello,abrt,your UID is 173
Hello,rpcuser,your UID is 29
Hello,nfsnobody,your UID is 65534
Hello,haldaemon,your UID is 68
Hello,ntp,your UID is 38
Hello,apache,your UID is 48
Hello,saslauth,your UID is 498
Hello,postfix,your UID is 89
Hello,gdm,your UID is 42
Hello,pulse,your UID is 497
Hello,sshd,your UID is 74
Hello,tcpdump,your UID is 72
Hello,mysql,your UID is 27
Hello,nginx,your UID is 496

  

最新文章

  1. Android 自定义View
  2. 关于Eclipse的unsupported major minor version 51.0 错误
  3. SQL行转列
  4. Jquery 学习二
  5. 暑假集训(2)第二弹 ----- The Suspects(POJ1611)
  6. GWT(Google Web Tookit) Eclipse Plugin的zip下载地址(同时提供GWT Designer下载地址)
  7. Mysql服务启动问题
  8. Matlab中K-means聚类算法的使用(K-均值聚类)
  9. 使用log4j日志-配置载入问题
  10. 业余草推荐18个Java开源免费的CMS系统
  11. 浅谈CSS3动画的凌波微步--steps()
  12. Hadoop:Hadoop简介及环境配置
  13. Qt快速入门第三版下载
  14. 最小可用id
  15. 关于mysql存储过程中传decimal值会自动四舍五入的这个坑
  16. ES6躬行记(7)——代码模块化
  17. Learning-Python【21】:Python常用模块(4)—— re、logging、hashlib、subprocess
  18. ionic tab显示到顶部去了
  19. SearchContextMissingException[No search context found for id [1545782]]
  20. 【javascript】内存泄露及其解决办法

热门文章

  1. TIMESTAMP(6)类型的时间差
  2. 多个Gesture响应原理
  3. 针对Oracle数据库中SCOTT方案的多表查询的一个例子
  4. Linux中 ./configure --prefix命令
  5. find 递归/不递归 查找子目录的方法
  6. Windows下phpstudy配置tp5的nginx时遇到的奇葩问题
  7. freeswitch dialplan 基础
  8. View控件跟随鼠标移动
  9. pwnable.kr-fd-witeup
  10. shell脚本简介