Archive
Posts in Shell
Fixing typos with bash
I frequently find myself make silly typing mistakes when changing between directories. Since this is especially annoying with long directory names, I use the bash cdspell option to transparently fix my typing mistakes. To set this nifty option, you can add the following line to your .bash_profile: This is a super useful option, and makes life a bit easier for folks with no typing skillz. Niiiiice!
$ read more →Amusing UNIX commands
While surfing the net this week, I came across a website with a list of several amusing UNIX command lines. I think my personal favorite is "man: why did you get a divorce?": It's all about a little humor! :)
$ read more →How long has a shell been active?
While reading through the bash documentation I came across the SECONDS variable: which provides the number of seconds a shell has been active. It is amazing how many useful nuggets of information are located in the bash documentation.
$ read more →Shifting with bash
While reading through the bash documentation last night I came across "let," ">>" and "<<": 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.
$ read more →Calculating variable sizes with bash
While perusing the bash documentation today I came across the ${#} built-in, which can be used to view the size of a variable: This could be useful for iterating through strings in a loop, and is now part of my shell programming crib notes. Niiiiiiiiiiiiiiiiice!
$ read more →