首页 > 其他 > 详细

while loop

时间:2019-10-06 18:45:37      阅读:84      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!