#!/bin/bash if [ $# != 3 ] then echo "Create a bunch of files with random contents." echo "Usage:" echo "$0 filename number size" echo " filename: basename of the file" echo " number : number of files to be created" echo " size : file size in bytes" exit fi for (( i = 0 ; i < $2 ; i++ )) do echo "Writing $3 bytes to $1.$i" dd if=/dev/urandom of=$1.$i bs=$3 count=1 > /dev/null done
which is not all that readable. There are code viewers on the web which converts the code to nicely formatted HTML, a quick googeling directs to e.g. this one:
http://codeformatter.blogspot.com/2009/06/about-code-formatter.html
#!/bin/bash
if [ $# != 3 ]
then
echo "Create a bunch of files with random contents."
echo "Usage:"
echo "$0 filename number size"
echo " filename: basename of the file"
echo " number : number of files to be created"
echo " size : file size in bytes"
exit
fi
for (( i = 0 ; i < $2 ; i++ ))
do
echo "Writing $3 bytes to $1.$i"
dd if=/dev/urandom of=$1.$i bs=$3 count=1
done
Right, formatting has improved, but there is still no syntax highlighting. The best solution I could find is the one at http://tohtml.com
#!/bin/bash if [ $# != 3 ] then echo "Create a bunch of files with random contents." echo "Usage:" echo "$0 filename number size" echo " filename: basename of the file" echo " number : number of files to be created" echo " size : file size in bytes" exit fi for (( i = 0 ; i < $2 ; i++ )) do echo "Writing $3 bytes to $1.$i" dd if=/dev/urandom of=$1.$i bs=$3 count=1 done
which looks the way I wanted it!
Now I just have to figure out what to do with thousands of 1k garbage files flocking around in my directory.