Shifting with bash


While reading through the bash documentation last night I came across “let,” “»” and “«”:

$ let "fluffy = 1<<5"

$ echo fluffy
32

let allows you to assign a value to a variable, « allows you to shift a value X bits to the left (5 in the example above), and » allows you to shift a value X bits to the right. This sure beats running xcalc and/or bc.

This article was posted by Matty on 2006-02-15 22:39:00 -0400 -0400