Bourne shell idioms

Here are some portable Bourne shell idioms that I find useful to remember for scripting. The Bourne shell does much more than most users realize, and the ksh and bash extensions are rarely essential. (From the command-line, bash and ksh are vastly more useful.)

My favorite reference book is "Portable Shell Programming --- An Extensive Collection of Bourne Shell Examples" by Bruce Blinn from Prentice Hall.

Get information on a built-in bash command with help. It's much easier than reading the full bash man page at http://www.gnu.org/software/bash/manual/bash.html

For Bash suggestions, I recommend this bash FAQ: http://mywiki.wooledge.org/BashFAQ/

§    Text filtering commands

Administrating from scripts and the command-line often benefit from pipes of text filtering commands. Here are some that are easy to overlook or forget.

§    Files and directories

§    Variables

§    Running commands

§    Manipulating paths

§    Common script chores

§    File descriptors

  • Hostname lookups on linux

    General utilities are dig, nslookup, host, hostname.

    Get an IP address for a specific hostname:
    host samplehostname | sed 's/.* //'
    

    Get a hostname for an IP address:
    nslookup 123.123.123.123 | grep 'name = ' | sed 's/.*name = //'
    


    Return to parent directory.