Last active
August 29, 2015 14:21
-
-
Save ervinb/c45b9ac8a90b775e7347 to your computer and use it in GitHub Desktop.
Creates N sample files of defined size
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 | |
die () { | |
echo >&2 "$@" | |
exit 1 | |
} | |
[ "$#" -eq 2 ] || die "2 arguments required -- <file count> <size>, only $# provided!" | |
echo $1 | grep -E -q '^[0-9]+$' || die "Numeric argument required, $1 provided!" | |
echo $2 | grep -E -q '^[0-9]+M|K$' || die "Define the size as <number>M|K, $2 provided!" | |
arg_files_to_create=$1 | |
arg_file_size=$2 | |
echo "Creating $arg_files_to_create files of $arg_file_size" | |
for i in `seq $arg_files_to_create`; do | |
truncate -s $arg_file_size trunc-file-$i.dat | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment