码迷,mamicode.com
首页 > 其他好文 > 详细

while loop

时间:2019-10-06 18:26:43      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:rand   ash   oop   har   done   else   nbsp   head   fine   

1. create a function to generate file with the filename start with 10 random characters

#!/bin/bash
WORK_DIR=/tmp/00
#define the function
create(){
    i=1
    while [ $i -le 5 ]
    do
if [ ! -d $WORK_DIR ]
then
mkdir -p $WORK_DIR cd $WORK_DIR && touch `</dev/urandom tr -dc "a-z" | head -c 10`_test.txt
else
          cd $WORK_DIR && touch `</dev/urandom tr -dc "a-z" | head -c 10`_test.txt
fi
       i=$(( $i+1 )) 
done
}
# invoke the function
create

  

 

while loop

标签:rand   ash   oop   har   done   else   nbsp   head   fine   

原文地址:https://www.cnblogs.com/amy2012/p/11627860.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!