Of the major Unix shells (bash, ksh, tcsh, zsh, others?), are there any compelling reasons to use one over another?
- Which is the most interactive/command-line friendly?
- Which is the most conducive/intuitive for writing scripts?
- Are there any major built-in features that one shell offers that others don't?
- Are any of these shells really good for one type of function, but not another? Or are they all pretty well-rounded/flexible?
- Is it just a matter of personal preference?
I can make this community wiki if anyone prefers.
Current:
bash
— Bourne again shell, default shell in most Linux distributions. Decent features;zsh
— the most feature rich, but still rarely used;ksh
— default shell in Solaris, AIX and other few other unices;tcsh
— default shell in various *BSD flavor unices;Historic:
sh
— original Bourne shell (released 1977). Obsoleted by bash;csh
— original C shell (released 1978). Obsoleted by tcsh and ksh;Note, that bash, ksh and zsh derive from sh syntax, while tcsh derives from csh syntax. This are two quite different syntaxes.
The feature chart (wiki).
fish is a new shell that is perhaps more interesting than the others, not because it necessarily has more features, but because they Just Work by default and because fish strives for usability.
A few screenshots (1, 2, 3, 4) are enough to give the general idea.
fish is now the default shell on my Mac at work. Go figure.
If you're going to learn a shell other than
sh
/bash
, you might as well just go withzsh
. I don't think anyone seriously contests that it's the most powerful and feature-packed of the alternative shells; whether it's just bloat is, of course, still up for debate.I've heard good things about
fish
, but never worked up the effort to bother with them.The admins I know consider
csh
andtcsh
to be abominations that should be avoided at all costs, and I agree with them despite never having been forced to put myself through either shell.I would recommend knowing bash well as it is one of the most common (generally the Linux default). Personally, I love zsh as my interactive shell. It has great completion features. For example, you can set a list of hosts and when you do something like ssh Ser[tab] it will know to try to tab auto complete one of those hosts. It also has recursive globing, so if you want to find all jpeg files in the current and subdirectory you can use
ls -ld **/*.jpg
. There are lots of fun features with zsh (search for people's .zshrc files), and you can set it to 'bash compatible', so it is easy to switch between the two. If you combine this with GNU Screen you might find the command line becomes quite a pleasure to work with.Don't forget your other question Most common Unix/Linux shell - the most popular shell is probably most popular for a reason ;-)
For what it's worth, most people don't switch off between shells frequently so it'll be hard to get a well-rounded comparison of the various options; you'll be more likely to see different people espousing the virtues of their favorite shells. From what little I've heard about different shells, they all offer some of the same basic features (like I/O redirection, command history, etc.) so personal preference is likely to be a large component.
A compelling reason to use ZSH that has not been mentioned is vi mode and emacs mode.
For those who love to use their vi muscle memory in the shell, this is a killer feature.
And for those who prefer emacs, you can use those keybindings too, but true emacs-believers would probably say that emacs is their favorite shell.
;-)
Preference for day to day use is really a mather of personal taste, however, when writing scripts, I try to be posix compliant for portabilities sake.
Just as Heads Up: Ubuntu defaults "sh" to "dash" which lead to some problems in the past with POSIX compability. Apparently, the echo commands differ slightly.