Skip to content

Instantly share code, notes, and snippets.

@iAnatoly
Last active May 6, 2022 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iAnatoly/cd4333479c83953ba71445168c5c78a5 to your computer and use it in GitHub Desktop.
Save iAnatoly/cd4333479c83953ba71445168c5c78a5 to your computer and use it in GitHub Desktop.
Generate given number of random files
#!/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