Last active
May 6, 2022 18:15
-
-
Save iAnatoly/cd4333479c83953ba71445168c5c78a5 to your computer and use it in GitHub Desktop.
Generate given number of random files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TARGET_FILE_NUM=$1 | |
CURRENT_FILE_NUM=`ls -l | wc -l` | |
FILES_TO_GENERATE=$((TARGET_FILE_NUM - CURRENT_FILE_NUM)) | |
if [[ $FILES_TO_GENERATE -lt 0 ]]; then | |
echo "We already have $CURRENT_FILE_NUM files, no need to generate more" | |
exit | |
fi | |
echo "Generating $FILES_TO_GENERATE more files in order to acheive the goal of $TARGET_FILE_NUM" | |
for i in $(seq $CURRENT_FILE_NUM $TARGET_FILE_NUM); | |
do | |
printf "." | |
if [ $((i % 100)) -eq 0 ]; then | |
printf $i | |
fi | |
uuid=`uuidgen` | |
newname="imqa_${uuid}" | |
head -c $(($RANDOM/10+1)) </dev/urandom > $newname | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment