script to make random junk files of specific sizes
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/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