Skip to content

Instantly share code, notes, and snippets.

@sdmcraft
Created February 12, 2019 11:31
Show Gist options
  • Save sdmcraft/be8ad958f5dbcd38a07d2d47afff62a1 to your computer and use it in GitHub Desktop.
Save sdmcraft/be8ad958f5dbcd38a07d2d47afff62a1 to your computer and use it in GitHub Desktop.
Append garbage to files
#!/bin/bash
usage()
{
echo -e "Usage: $0 -i <input folder path containing files to append garbage> -b <garbage size>" \
"\nExample Usage: ./append-garbage.sh -i ~/Pictures/000-large -b 10M" 1>&2; exit 1;
}
while getopts i:b: option
do
case "${option}"
in
i) SOURCE_FOLDER=${OPTARG};;
b) GARBAGE_SIZE=${OPTARG};;
*) usage;;
esac
done
dd if=/dev/zero of=garbage.dat bs=$GARBAGE_SIZE count=1
for FILE in $SOURCE_FOLDER/*
do
cat garbage.dat >> $FILE
done
rm garbage.dat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment