Sometimes it's useful to trigger an action after a file is closed. Suppose you started a lengthy download on your notebook and you want to suspend it as soon as the download is done. There are several ways to achieve this.
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 …
Classic Bourne Shell has a handy feature that many people don't seem to know: Parameter Expansion. Stephen Bourne describes it in An Introduction to the UNIX Shell, which is part of the original Unix V7 manuals from 1978. Among other things, parameter expansion provides a notation for making sure that …
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.
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 …
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.
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 ...
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 …
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: