memory size

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

memory size

Eben King
I wrote this Q+D script to demonstrate how much (how little) text was a
kilobyte (my friend and I were talking about our first computers).  It can
be adjusted for any amount.  It takes no arguments, all adjustments are done
by editing the source.  Spaces don't count toward the character total.

#! /bin/bash
# end configurable options

randmax=32768 # this has no significance to bash
spacecode=32 # decimal ASCII code for a space
spacelimit=$(( randmax - randmax / ( wordlength + 1 ) )) # if RANDOM > this,
print a space

while [ $counter -lt $characters ] ; do
   thisrandom=$RANDOM # RANDOM = bash PRNG
   if [ $thisrandom -gt $spacelimit ] ; then
     charactercode=$(( 97 + thisrandom % 26 )) # 97=ASCII code for "a"
     counter=$(( counter + 1 ))
   echo $charactercode P
done | dc | fold -w 80 -s

-eben    [hidden email]    ebmanda.redirectme.net:81
LIBRA:  A big promotion is just around the corner for someone
much more talented than you.  Laughter is the very best medicine,
remember that when your appendix bursts next week.  -- Weird Al
slug mailing list
[hidden email]