As time goes by, there are certain things from the past that stick with us, aren't there? Things that won't quickly be forgotten. Just the other day I was thinking it's been a while since I've seen the good old format c:
screen. I remember seeing that screen a lot back when I was a Windows user. All the way from Windows 3.1 to Windows XP, ever so often I would format and reinstall the system. And formatting was the simplest way to start with a clean slate (virus and spyware wise, in later years), it was much quicker than deleting all the files.
The format command also had this mythical quality about it. It was synonymous with destruction, with sabotage even. Whenever we joked about messing up someone's system, we would always joke about formatting c:. I don't recall ever actually doing that to someone for amusement, but it was certainly tempting at times (on school computers especially :D ).
But then I remember one time back in high school, years later, when a friend of mine threw a party for our class. Lots of people showed up that noone seemed to know, but his house was big enough to fit everyone in. A couple of days after the party, he was telling me that at around 1am, at a time when the party was well underway, he came into his room, found his computer was on and the format c:
screen was staring him in the face, with the counter at 80%. He said he immediately cut the power. He then turned it back on, the system hadn't been wiped yet. What a relief.
So with this in mind, it occurred to me recently that it would be fun to recreate the mythical format c:
screen, given that I never see it anymore. It took me a while to figure out how to print characters and then delete them in bash, but here is the code that recreates the actual format c:
screen. It's shown in the screenshot above. The font isn't correct, unless you have your terminal running on the original Lucida Mono font that Ms DOS came with. But other than that, I've tried to recreate it to a T.
#!/bin/bash
if [ "$1" = "" ]; then
echo "Required parameter missing -"
exit 1
fi
drive=$(echo $1 | tr [:lower:] [:upper:])
sp="\0040"
bs="\0010"
spaces() {
e=""
for i in $(seq 1 $1); do
e="${e}${sp}"
done
echo $e
}
el=$(spaces 50)
label1="\n\nWARNING: ALL DATA ON NON-REMOVABLE DISK
\nDRIVE $drive WILL BE LOST
\nProceed with Format (Y/N)?"
label2="\n\n
\nChecking existing disk format.
\nRecording current bad clusters"
proc1="Complete. $el
\nVerifying 1,023.71M"
proc2="Format complete. $el
\nWriting out file allocation table"
proc3="Complete. $el
\nCalculating free space (this may take several minutes)..."
proc4="Complete. $el
\n\nVolume label (11 characters, ENTER for none)?${sp}"
label3="\n
\n1,071,337,472 bytes total disk space
\n1,071,337,472 bytes available on disk
\n
\n$(spaces 8)4,096 bytes in each allocation unit.
\n$(spaces 6)261,556 allocation units available on disk.
\n\nVolume Serial Number is 1E36-1EF5\n\n\n"
type_delay=0.3
counter_delay_short=0.05
counter_delay_vshort=0.005
counter_delay_long=0.3
cmd_delay=1
pause() {
sleep $cmd_delay
}
print() {
for i in $(seq 0 ${#1}); do
c=${1:$i:1}
if [ "$c" = " " ]; then
c=$sp
fi
echo -ne $c
sleep $type_delay
done
}
counter() {
for i in $(seq 1 100); do
l="${sp}$i percent completed."
echo -ne $l
sleep $1
for j in $(seq 0 ${#l}); do
echo -en $bs
done
done
}
echo -en $label1
pause
print "y"
echo -e $label2
counter $counter_delay_short
echo -e $proc1
counter $counter_delay_long
echo -e $proc2
counter $counter_delay_short
echo -e $proc3
counter $counter_delay_vshort
echo -en $proc4
pause
print "l33t h4xx0r"
echo -en $label3
What it does is... absolutely nothing. Except simulating what happens when you type C:\>format c: [ENTER]
in Ms DOS. To run it, download the file, chmod 755 format
it, and copy it to a path that is in your $PATH
, like /usr/local/bin
with cp format /usr/local/bin
. (you may have to use sudo
here, /usr/local/bin
is usually only writable by root). Now you have your very own format
command on linux and you can run format c:
whenever a bout of nostalgia hits you and you miss the old format
command.
Best of all, it doesn't actually nuke your files, but you can still use it to scare the bejeezus out of people. ;) :devil: :D And since you just set its permissions to be executed by any user, any user can run it (perhaps with some persuasion? ;) :D ).
That's interesting :D
That's pretty cool. I write these little "simulator" codes when I get bored as well. It's nice to know I'm not the only one that writes weird little useless codes. :) Keep it up.