Shell programmingThis is about scripts and functions for
Most of the shell scripts and functions shown here work well with both
Functions use local variables wherever possible, in order to keep the shell
environment intact. Some of them, however, have to use
Files can be downloaded individually or as a whole (button at the left). Shorter functions are quoted in the text. All of them require a sufficiently new shell version. They have been tested with bash-3.2 and ksh-1993-12-28s+ (2007-11-05).
Some people keep advising others in newsgroups to write "compatible" scripts, that is, to ignore the capabilities of modern shells and restrict themselves to the archaic Bourne shell standard. This may make sense for users who desperately want their scripts to run on the oldest and obscurest unixoid systems (though even then there is no guarantee). Those, however, who are satisfied with scripts that run on any current Linux system, or who simply write for themselves, can happily ignore this advice. The features of modern shells have been introduced for good reasons (to make programming easier and safer), and that's why they are used consequently in the scripts presented here.
 Of course there are more shells, each of which has its pros and cons. I concentrate on bash and ksh because I'm familiar with them, and don't participate in religious shell wars.