Skip to content

Instantly share code, notes, and snippets.

@vaz
Created August 11, 2019 00:32
Show Gist options
  • Save vaz/86f1bcc13f57b18b75df29fad2094d40 to your computer and use it in GitHub Desktop.
Save vaz/86f1bcc13f57b18b75df29fad2094d40 to your computer and use it in GitHub Desktop.
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