拼接
[root@web01 /oldboy]# ls *.html|awk -F "[_.]" '{print "mv"}'
mv
mv
mv
mv
mv
mv
mv
mv
mv
mv
[root@web01 /oldboy]# ls *.html|awk -F "[_.]" '{print "mv",$0}'
mv oldboy_affnopfpqy.html
mv oldboy_apdvdhzfsi.html
mv oldboy_cfkcbopkut.html
mv oldboy_eighyfyyay.html
mv oldboy_ejmzkzcewv.html
mv oldboy_gvgsexkibe.html
mv oldboy_kuxgpnflfn.html
mv oldboy_rslahqrxky.html
mv oldboy_sgduhepgtt.html
mv oldboy_sqlcafkzpj.html
[root@web01 /oldboy]# ls *.html|awk -F "[_.]" '{print "mv",$0,"oldgirl_"}'
mv oldboy_affnopfpqy.html oldgirl_
mv oldboy_apdvdhzfsi.html oldgirl_
mv oldboy_cfkcbopkut.html oldgirl_
mv oldboy_eighyfyyay.html oldgirl_
mv oldboy_ejmzkzcewv.html oldgirl_
mv oldboy_gvgsexkibe.html oldgirl_
mv oldboy_kuxgpnflfn.html oldgirl_
mv oldboy_rslahqrxky.html oldgirl_
mv oldboy_sgduhepgtt.html oldgirl_
mv oldboy_sqlcafkzpj.html oldgirl_
[root@web01 /oldboy]# ls *.html|awk -F "[_.]" '{print "mv",$0,"oldgirl_"$2}'
mv oldboy_affnopfpqy.html oldgirl_affnopfpqy
mv oldboy_apdvdhzfsi.html oldgirl_apdvdhzfsi
mv oldboy_cfkcbopkut.html oldgirl_cfkcbopkut
mv oldboy_eighyfyyay.html oldgirl_eighyfyyay
mv oldboy_ejmzkzcewv.html oldgirl_ejmzkzcewv
mv oldboy_gvgsexkibe.html oldgirl_gvgsexkibe
mv oldboy_kuxgpnflfn.html oldgirl_kuxgpnflfn
mv oldboy_rslahqrxky.html oldgirl_rslahqrxky
mv oldboy_sgduhepgtt.html oldgirl_sgduhepgtt
mv oldboy_sqlcafkzpj.html oldgirl_sqlcafkzpj
[root@web01 /oldboy]# ls *.html|awk -F "[_.]" '{print "mv",$0,"oldgirl_"$2".HTML"}'
mv oldboy_affnopfpqy.html oldgirl_affnopfpqy.HTML
mv oldboy_apdvdhzfsi.html oldgirl_apdvdhzfsi.HTML
mv oldboy_cfkcbopkut.html oldgirl_cfkcbopkut.HTML
mv oldboy_eighyfyyay.html oldgirl_eighyfyyay.HTML
mv oldboy_ejmzkzcewv.html oldgirl_ejmzkzcewv.HTML
mv oldboy_gvgsexkibe.html oldgirl_gvgsexkibe.HTML
mv oldboy_kuxgpnflfn.html oldgirl_kuxgpnflfn.HTML
mv oldboy_rslahqrxky.html oldgirl_rslahqrxky.HTML
mv oldboy_sgduhepgtt.html oldgirl_sgduhepgtt.HTML
mv oldboy_sqlcafkzpj.html oldgirl_sqlcafkzpj.HTML
[root@web01 /oldboy]# ls *.html|awk -F "[_.]" '{print "mv",$0,"oldgirl_"$2".HTML"}'|bash
[root@web01 /oldboy]# ls
a.sh oldgirl_cfkcbopkut.HTML oldgirl_gvgsexkibe.HTML oldgirl_sgduhepgtt.HTML
oldgirl_affnopfpqy.HTML oldgirl_eighyfyyay.HTML oldgirl_kuxgpnflfn.HTML oldgirl_sqlcafkzpj.HTML
oldgirl_apdvdhzfsi.HTML oldgirl_ejmzkzcewv.HTML oldgirl_rslahqrxky.HTML
image.png
创建用户,密码是随机数
#!/bin/bash
. /etc/init.d/functions
for user in oldboy{19..25}
do
passwd=`echo $user|md5sum|cut -c 1-8`
if [ `id $user 2>/dev/null|wc -l` -ge 1 ]
then
action "$user is no" /bin/false
continue
else
useradd $user &>/dev/null &&{
echo "$passwd"|passwd --stdin $user &>/dev/null
echo -e "$user\t$passwd" >>/tmp/user.txt
}
if [ $? -eq 0 ]
then
action "$user is ok" /bin/true
else
action "$user is no" /bin/false
fi
fi
done
[root@web01 scripts]# cat char.txt
21029299
00205d1c
a3da1677
1f6d12dd
890684b
[root@web01 scripts]# tr "\n" "|" < ./char.txt
21029299|00205d1c|a3da1677|1f6d12dd|890684b|[root@web01 scripts]#
[root@web01 scripts]#
[root@web01 scripts]#
[root@web01 scripts]# cat 12_4_1.sh
#!/bin/bash
##############################################################
# File Name: 12_4.sh
# Version: V1.0
# Author: oldboy
# Organization: [图片上传失败...(image-e722b-1559701925426)]
www.oldboyedu.com
##############################################################
#for n in {0..32767}
#do
# echo -n "$n " >>/tmp/md5sum.txt
# echo $n|md5sum >>/tmp/md5sum.txt
#done
egrep "21029299|00205d1c|a3da1677|1f6d12dd|890684b" /tmp/md5sum.txt
------------------------------------------------------------------------------------
[root@oldgirl scripts]# cat 19_18_1.sh
#!/bin/sh
array=( #<==把待比较的字符串信息放到数组里。
21029299
00205d1c
a3da1677
1f6d12dd
890684b
)
Path=/tmp/md5.txt
funGetMd5() {
> $Path
for ((Num=0;Num<=32767;Num++))
do
{
Stat=$(echo $Num|md5sum)
echo "$Stat $Num" >> $Path #<==建立数字和md5sum后的内容对应关系。
}&
done
}
funFindMd5() {
word=$(echo "${array[@]}"|sed -r 's# |\n#|#g') #<==取出所有数组元素并用|分隔开。
grep --color=auto -E "$word" $Path #<==同时过滤包含所有不同字符串的内容。
}
funcMain(){
funGetMd5
funFindMd5
}
funcMain
[root@web02 ~]# cat a.sh
for dbname in `mysql -uroot -poldboy123 -e "show databases;" 2>/dev/null|sed 1d|egrep -v "_schema"`;
do
mysqldump -uroot -poldboy123 -B $dbname 2>/dev/null|gzip >/tmp/${dbname}_$(date +%F).sql.gz;
done
[root@web02 ~]# cat b.sh
for dbname in `mysql -e "show databases;"|sed 1d|egrep -v "_schema"`;
do
mysqldump -B $dbname|gzip >/tmp/${dbname}_$(date +%F).sql.gz;
done
网友评论