Skip to content

Instantly share code, notes, and snippets.

@ervinb
Last active August 29, 2015 14:21
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 ervinb/c45b9ac8a90b775e7347 to your computer and use it in GitHub Desktop.
Save ervinb/c45b9ac8a90b775e7347 to your computer and use it in GitHub Desktop.
Creates N sample files of defined size
#! /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