Created
February 12, 2019 11:31
-
-
Save sdmcraft/be8ad958f5dbcd38a07d2d47afff62a1 to your computer and use it in GitHub Desktop.
Append garbage to files
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 | |
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