shell批量修改文件名方法

1.
创建
[root@shnne ~]# cat mk.sh 
#!/bin/sh
for((i=1; i<=10; i++))
do
  j=`cat /dev/urandom|head -1|md5sum|cut -c 1-5`
  touch shnne/${j}_shnne_$i.html
done

修改
[root@shnne ~]# cat mod.sh 
#!/bin/sh
cd /root/shnne
for i in `ls *.html`
do
   mv $i `echo $i|sed 's#\(.*\)shnne\(.*\).html#\1linux\2.HTML#g'`
done

2.
通过rename方式
rename shnne linux *.html
分享到:
关键词:Linux运维Shell

<< 上一篇

for小练习

下一篇 >>

continue,break,exit小例子

网友留言(0 条)

发表评论