RSS Feed Share on Twitter

Buy this tutorial as a PDF for only $5!

All Shell Scripting Tips

31 Oct 2018


Why is Christmas the same day as Halloween?

Because in Decimal (Dec, also short for December), we count units (ones) on te right hand column, then 10s to the left of that (then hundreds, thousands, etc, as we go further left). But in Octal (Oct, also short for October), we count units (ones) on the right hand column, then 8s, then 64s, 512s, and so on - multiplying by 8, rather than 10, every time.

So in Base 10, Decimal, "25" means "(2 x 10) + (5 x 1)" but in Base 8, Octal, "31" means "(3 x 8) + (1 x 1)".

3 x 8 = 24, and 1 x 1 = 1, so "Oct 31" is "Dec (24+1)" which is "Dec 25"

You can also convert between bases in the Bash shell; if you've declared HALLOWEEN to be a decimal integer (with the "declare -i HALLOWEEN") command), then "HALLOWEEN=8#31" won't set it to that literal string, but will instead set it to the value of "31" in Base 8:

$ declare -i HALLOWEEN



Books and eBooks


You can mail me with this form. If you expect a reply, please ensure that the address you specify is valid. Don't forget to include the simple addition question at the end of the form, to prove that you are a real person!

You can buy the content of this Shell Scripting Tutorial as a PDF!