linux shell 生成随机字符串脚本
2015-05-30 22:18
567 查看
脚本作用:
生成特定长度的字符串,只包含数字或者大小写字母。
count定义字符串的长度
number定义字符串的数目
line定义生成多少个随机字符串,如果number值很大,相应的将line值调大。
由于pv1中的字符串长度不是固定的,所以需要经过一个for循环进行字符串筛选。
以下是脚本命令:
#!/bin/bash
count=6
line=100
number=10
touch /root/pv1.txt
cat /dev/urandom |sed 's/[^a-zA-Z0-9]//g'|strings -n $count |head -n $line|grep -i '^[a-z]'|sort > /root/pv1.txt
touch /root/pv$count.txt
for i in `cat /root/pv1.txt`;do
[ ${#i} -eq $count ] && echo $i >>pv2txt
done
touch /root/password$number.txt
head -10 /root/pv2.txt > /root/password$number.txt
生成特定长度的字符串,只包含数字或者大小写字母。
count定义字符串的长度
number定义字符串的数目
line定义生成多少个随机字符串,如果number值很大,相应的将line值调大。
由于pv1中的字符串长度不是固定的,所以需要经过一个for循环进行字符串筛选。
以下是脚本命令:
#!/bin/bash
count=6
line=100
number=10
touch /root/pv1.txt
cat /dev/urandom |sed 's/[^a-zA-Z0-9]//g'|strings -n $count |head -n $line|grep -i '^[a-z]'|sort > /root/pv1.txt
touch /root/pv$count.txt
for i in `cat /root/pv1.txt`;do
[ ${#i} -eq $count ] && echo $i >>pv2txt
done
touch /root/password$number.txt
head -10 /root/pv2.txt > /root/password$number.txt
相关文章推荐
- Linux Shell脚本攻略(1.8)
- xshell简单使用入门
- xshell xftp 5系列
- [shell] Bash编程总结
- shell <<EOF
- linux学习笔记—shell脚本执行方式
- HBASE Shell
- PowerShell中进行文件读取,信息排序,分类计数。
- linux学习笔记—shell概述
- KalilMetasploit生成cmdshell(未免杀)
- Linux&nbsp;Shell常用技巧(目录)
- shell脚本学习
- tlcl-从shell眼中看世界echo
- Bash中的特殊字符
- Linux Bash编程
- [LeetCode][Shell]Tenth Line
- Linux Shell脚本攻略(1.7)
- BASH
- win7(windows) 下 git bash 调用 notepad++ 或者其他编辑器的方法
- shell