Other articles

  1. Quick Tip #5: Navigating in Source Trees

    I often move around in checked out Subversion or Git source trees on a Bash command line. Directory structures tend to get quite deep (especially in Java projects), so one problem keeps coming up frequently: Changing back to the base directory of the source tree. Typing "cd .." ten times is …

    read more
  2. Scripts That Just Don't Work

    Sometimes people ask for my help when their shell scripts don't work. I've seen all kinds of problems, ranging from trivial to really, really weird. The one I'm describing in this article is definitely from the weird category, but I've seen it quite a few times.

    The story goes like …

    read more
  3. Quick Tip #4: Sorting Large Files

    With traditional Unix sort(1), the size of the files you can sort is limited by the amount of available main memory. As soon as the file gets larger and your system has to swap, performance degrades significantly. Even GNU sort which uses temporary files to get around this limitation …

    read more
  4. Quick Tip #2: Set Operations Using Shell Tools

    Everybody knows that Unix shell utilities are powerful. Even though they're text-based, you can build a lot of useful things outside of the text domain. Today I'll show you how to implement set operations. All we need are sorted files as input, with each file representing a set.

    Let's create …

    read more
  5. Quick Tip #1: Implicit FIFOs in Bash

    One could assume that I have run out of material and retreat to safer ground, but far from it. From now on I'll just throw in a few quick shell hacks hoping some of you don't know them yet. So, here it goes ...

    Unix pipes are cool, but it's quite …

    read more
  6. Parsing Command Line Options in Shell Scripts

    In programs written in C, command line argument parsing has always been done using the getopt(3) library function. This function has set the standards Linux/Unix users have come to expect from command line interfaces. Fortunately, there's a getopt(3) equivalent for almost every programming language and the shell …

    read more
  7. Changing Directories Quickly

    When you work with the interactive shell, there's a common pattern that is used a lot: Copying or moving files to a directory and then changing to the target directory using cd. In these cases, you find yourself typing the name twice:

    $ cp file1 file2 file3 /very/long/path/name …
    read more