您的位置:首页 > 理论基础 > 计算机网络

脚本-根据ip和mask获取网络地址

2012-02-22 17:50 274 查看
上周导师留得shell题目,代码不是很完整,不过已经满足需求了,毕竟shell对于dba或者系统管理员来说能满足业务需求就可以了,给自己用的,简单明了ok。供大家参考

需求:

编写SHELL脚本,生成文本文件user.txt,包含三个字段,对应user表,例如:
#用户id,用户名,用户密码(md5加密串),记录数不低于10000条
1,u1, 78d0fb209cf7cb738d11e559a698858c
用处:用于数据库的批量导入

问题:这样10000条数据shell生成效率并不是很高,导师说c语言效率会高些,有时间研究一下。

# !/bin/bash
# Touch /home/test/user.txt
# the text format is "uid,username,passwd"
# The number of users is 10000

# if the file has exists,then drop off it,else touch it.
filename=/home/test/user.txt
if test -f $filename
then
rm -f $filename
else
touch $filename
fi

# create 10000 users in "/home/test/user.txt"
for i in $( seq 1 10000)
do
echo "$i,user$i,`echo user$i | md5sum | awk '{print $1}'`" >> $filename
done


本文出自 “Saadiya灬求知若渴” 博客,请务必保留此出处http://saadiya.blog.51cto.com/2805761/786955
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: