1.批量生成随机字符文件名;在/tmp目录下批量创建10个html文件,
其中每个文件需要包含10个随机小写字母加固定字符串tmp
#!/bin/bash
for i in {1..10}
do
a=` mktemp | awk -F. '{print $2}'|tr A-Z a-z`
touch /tmp/$a.html
done
# apquvdpqbk_tmp.html
# mktemp | awk -F. '{print $2}',利用正则来生成也可
2.批量修改名称,后缀修改为大写
#!/bin/bash
ls /tmp/ |grep html$ >a1
file="a1"
for i in $(cat $file)
do
a2=` echo $i |awk -F. '{print $1}'`
a3=".HTML"
mv /tmp/$i /tmp/$a2.$a3
done
# apquvdpqbk_tmp.html ---> apquvdpqbk_tmp.HTML
ls /tmp | egrep "*.html$" > c
file="c"
for i in $(cat $file)
do
b=`echo $i | awk -F. '{print $1}'`
a=".
其中每个文件需要包含10个随机小写字母加固定字符串tmp
#!/bin/bash
for i in {1..10}
do
a=` mktemp | awk -F. '{print $2}'|tr A-Z a-z`
touch /tmp/$a.html
done
# apquvdpqbk_tmp.html
# mktemp | awk -F. '{print $2}',利用正则来生成也可
2.批量修改名称,后缀修改为大写
#!/bin/bash
ls /tmp/ |grep html$ >a1
file="a1"
for i in $(cat $file)
do
a2=` echo $i |awk -F. '{print $1}'`
a3=".HTML"
mv /tmp/$i /tmp/$a2.$a3
done
# apquvdpqbk_tmp.html ---> apquvdpqbk_tmp.HTML
ls /tmp | egrep "*.html$" > c
file="c"
for i in $(cat $file)
do
b=`echo $i | awk -F. '{print $1}'`
a=".