Created
June 12, 2019 20:06
-
-
Save JorgeFrancoIbanez/15b2f34bd46103bace5f6cc531d18608 to your computer and use it in GitHub Desktop.
Create folder with X quantity of files with specific size for testing purposes
This file contains 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 | |
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then | |
echo "Usage: $0 <dir_path> <number_of_files> <block_size>" | |
echo "parameters" | |
echo " - dir_path Directory path where the tests files will be created." | |
echo " - number_of_files The max number of files to be created at dir_path location." | |
echo " - block_size The Size of each test file in Kilobyte[K], Megabyte[M], Gigabyte[G]." | |
else | |
path=$1 | |
limit=$2 | |
size=$3 | |
if [[ ! -e $path ]]; then | |
mkdir $path | |
elif [[ ! -d $path ]]; then | |
echo "$path already exists but is not a directory" 1>&2 | |
fi | |
for i in `seq 1 $2`; | |
do | |
echo $i; | |
dd if=/dev/urandom of=$path/test$i bs=$size count=1; | |
done | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment