31 Oct 2018
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 $ HALLOWEEN=8#31 $ echo $HALLOWEEN 25 $
My Shell Scripting books, available in Paperback and eBook formats. This tutorial is more of a general introduction to Shell Scripting, the longer Shell Scripting: Expert Recipes for Linux, Bash and more book covers every aspect of Bash in detail.
![]() Shell Scripting Tutorial is this tutorial, in 88-page Paperback and eBook formats. Convenient to read on the go, and in paperback format good to keep by your desk as an ever-present companion. Also available in PDF form from Gumroad:Get this tutorial as a PDF | ![]() Shell Scripting: Expert Recipes for Linux, Bash and more is my 564-page book on Shell Scripting. The first half covers all of the features of the shell in every detail; the second half has real-world shell scripts, organised by topic, along with detailed discussion of each script. |