標籤:
[[email protected] wyb]# cat test10.sh #!/bin/bash#使用for迴圈在/test10目錄下通過隨機小寫10個字母加固定字串oldboy大量建立10個html檔案dir=/root/wyb/test10/[ ! -d $dir ] && mkdir -p $dirfor i in `seq 10`do touch $dir`echo $RANDOM|md5sum|cut -c 1-10`_oldboy.htmldone[[email protected] wyb]# bash test10.sh[[email protected] wyb]# cd test10[[email protected] test10]# ls3fb16229e0_oldboy.html 5bf08cf5ce_oldboy.html 73e073e1e6_oldboy.html 860bafa69b_oldboy.html c0b0067928_oldboy.html512c517124_oldboy.html 7245bf5bea_oldboy.html 76f98bef45_oldboy.html 94a1245d85_oldboy.html f37ace5e6a_oldboy.html[[email protected] test10]#
[[email protected] wyb]# cat xiugai.sh #!/bin/bash#將test10目錄下的檔案oldboy全部改成oldgirl(用for迴圈實現),並且html改成大寫。#3fb16229e0_oldboy.html 5bf08cf5ce_oldboy.html 73e073e1e6_oldboy.html 860bafa69b_oldboy.html c0b0067928_oldboy.html#512c517124_oldboy.html 7245bf5bea_oldboy.html 76f98bef45_oldboy.html 94a1245d85_oldboy.html f37ace5e6a_oldboy.htmlcd test10for i in `ls` do a=`echo $i|cut -c 1-10` mv ${a}_oldboy.html ${a}_oldgirl.HTMLdone[[email protected] wyb]# bash xiugai.sh [[email protected] wyb]# cd test10[[email protected] test10]# ls3fb16229e0_oldgirl.HTML 5bf08cf5ce_oldgirl.HTML 73e073e1e6_oldgirl.HTML 860bafa69b_oldgirl.HTML c0b0067928_oldgirl.HTML512c517124_oldgirl.HTML 7245bf5bea_oldgirl.HTML 76f98bef45_oldgirl.HTML 94a1245d85_oldgirl.HTML f37ace5e6a_oldgirl.HTML[[email protected] test10]#
shell指令碼,在指定目錄下通過隨機小寫10個字母加固定字串oldboy大量建立10個html檔案。