Skip to content

Instantly share code, notes, and snippets.

@vaz vaz/mkdata.sh
Created Aug 11, 2019

Embed
What would you like to do?
script to make random junk files of specific sizes
#!/bin/sh
set -e
function randomfile {
local numbytes="$1"
local outfile="$2"
{ cat /dev/urandom | # read random byte stream
base64 | # base64-encode the garbage so it's safely printable
fold -w 79 | # fold lines at 79 chars (80 char line w/ newline)
head -c"$numbytes" # read n chars then stop
} > "$outfile"
echo "$(cat "$outfile" | wc -c) random bytes written to $outfile"
}
randomfile 50000 ./data1.txt
randomfile 20 ./data2.txt
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.