Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Which shell do you use?

  • ksh

    Votes: 1 2.2%
  • bash

    Votes: 30 66.7%
  • zsh

    Votes: 3 6.7%
  • tcsh

    Votes: 8 17.8%
  • ash

    Votes: 0 0.0%
  • csh

    Votes: 3 6.7%
  • Other (please specify)

    Votes: 0 0.0%

  • Total voters
    45

Cromulent

macrumors 604
Original poster
Oct 2, 2006
6,827
1,131
The Land of Hope and Glory
So just for a bit of fun in the programming forum - which shell do you use? Perhaps include some information about why you use that shell.

I'm in the process of switching over to the zsh myself simply because I have never really learnt a shell and decided that zsh sounded like it had the most features along with a decent manual so I chose to learn that one.
 
I'm in the process of switching over to the zsh myself ...

Switching from what? For what reason(s)?

I'm fine using bash right now, because I don't need any extra power features. Even if I did need them, it might limit the compatibility of shell scripts I have to distribute. The shell scripts were often embedded in other programs, where the presence of the shell script was not plainly obvious to the user, so asking a user to install zsh was a non-starter. bash (or a bash-compatible shell) is practically everywhere.
 
Switching from what? For what reason(s)?

I've always used bash since that has been the default on every platform I use. I used ksh for a little bit on OpenBSD but never really used any shell properly.

The reason for switching is because I decided I needed to learn one shell properly and read some information about all the different shells and the general consensus was that zsh had the most features so I decided if I was going to spend the time learning a shell I might as well choose the one with the most features.
 
Interesting approach. Let me present a counter point. You state:
"I've always used bash since that has been the default on every platform I use"

So you're passing up ubiquity for some features that you haven't learned yet that you may never need. I guess it's my preference just to use bash because there is almost always bash. I haven't been stymied by a problem that using a different shell would have solved. Also, there's perl. If some shell thing gets too hairy perl is available widely enough that I'll just use that for complex scripting that my knowledge of bash can't address.

-Lee
 
Interesting approach. Let me present a counter point. You state:
"I've always used bash since that has been the default on every platform I use"

So you're passing up ubiquity for some features that you haven't learned yet that you may never need. I guess it's my preference just to use bash because there is almost always bash. I haven't been stymied by a problem that using a different shell would have solved. Also, there's perl. If some shell thing gets too hairy perl is available widely enough that I'll just use that for complex scripting that my knowledge of bash can't address.

-Lee

True. I've just been learning Vim for the last few months (does it ever stop? :)) and have noticed a huge improvement in my productivity. Especially as I now have all the plugins that help with C and Python programming. I was kind of hoping that spending the time to learn a shell (any shell really) would result in the same kind of productivity improvement and since the next computer I will be buying will be a PC running Linux (just can't justify the expense of another Mac with the specs that I need) I thought I might as well make the effort to start learning now.

In the past I've just used Python rather than shell scripting but I have at times had to read them which is quite tricky when you don't know the shell scripting language. Also as far as I am aware zsh makes big efforts to remain compatible with the original Bourne shell.
 
Last edited:
The reason for switching is because I decided I needed to learn one shell properly and read some information about all the different shells and the general consensus was that zsh had the most features so I decided if I was going to spend the time learning a shell I might as well choose the one with the most features.

Interesting choice. I would have chosen bash for its ubiquity. It has plenty of powerful features, most of which very few people learn.

After learning bash well, I might go on to zsh, which is also an enhanced Bourne shell. For me, the key is knowing bash well enough to know what's in bash and what's in other enhanced shells.

I don't think there's One Shell, just like I don't think there's One Programming Language. I think it's more useful to know several well enough, and be versatile and skilled enough to know when to apply each. If I had to learn zsh, there is no doubt that proficiency in bash would be the best foundation. And a good foundation has no substitute.


In the past I've just used Python rather than shell scripting but I have at times had to read them which is quite tricky when you don't know the shell scripting language.

Yes, knowing how to read shell scripts is a necessary skill.

Also as far as I am aware zsh makes big efforts to remain compatible with the original Bourne shell.
bash has much more than the original Bourne shell.


Here's a shell comparison chart:
http://en.wikipedia.org/wiki/Comparison_of_command_shells

It might not be detailed enough to see all the differences, but it does show some of the significant ones.
 
Last edited:
When I first moved to Mac OS X, I used tcsh. But that's only because I came from FreeBSD and I knew and was comfortable with tcsh. I wasn't a stranger to Bourne shells, it was just that I knew advanced techniques in tcsh that made me more productive.

This is the point I wanted to make. There's nothing wrong with using Python, if you're productive in it.
 
This is the point I wanted to make. There's nothing wrong with using Python, if you're productive in it.

Sure. But there is a lot more to a shell than simply scripting and I feel woefully uneducated in that area.

I've just bought a book called "Unix Power Tools" which I hope will give me a better understanding of everything (not that I am bad with Unix systems I just know I could be better with a bit of effort).
 
It sounds like you really want to be more comfortable and productive at the command line, not with the features of a shell. I think the book you're reading should help. Doing cool things with ssh, awk, grep, wc, at/cron, make, compilers, cat, echo, find, etc. and piping them all together is what allows for so much power. There are definitely interesting things you can do with your shell, but those features aren't my favorite tricks.

-Lee
 
It sounds like you really want to be more comfortable and productive at the command line, not with the features of a shell. I think the book you're reading should help. Doing cool things with ssh, awk, grep, wc, at/cron, make, compilers, cat, echo, find, etc. and piping them all together is what allows for so much power. There are definitely interesting things you can do with your shell, but those features aren't my favorite tricks.

-Lee

Yeah pretty much, although being more productive with the shell itself wouldn't hurt. I'm not bad when it comes to the main UNIX tools but I'd certainly like to get better at things in general.
 
Yeah pretty much, although being more productive with the shell itself wouldn't hurt. I'm not bad when it comes to the main UNIX tools but I'd certainly like to get better at things in general.

Here are a few bash tricks that should wet your appetite :

CTRL+R : recall a command from history. Just start typing and it will match. Hit CTRL+R to scroll through what it found.
CTRL+S : Stop scrolling. For long running commands with lots of input, you can stop the scrolling while you read a message.
CTRL+Q : Restart scrolling after a CTRL+S has been issued
CTRL+Z : Stop running task. Use the bg command to background a task that is stopped, use jobs to list them, fg to bring it back to the foreground.

CTRL+A : Go to the beginning of the line
CTRL+E : Go to the end of the line
CTRL+W : Erase the current or previous word (seperated by whitespace)

CTRL+C : Send the SIGINT signal

Up Arrow : Scroll through command history
Down Arrow : Scroll through command history

Tab : Complete file names

Learning an "obscure" shell just to be different is the wrong approach. Learn was is ubiquitous if you want to be versatile. Bash is almost guaranteed to be installed/installable on any Unix systems. Things like the zsh aren't (compiling anything on HP-UX is a challenge for example and finding packages for it isn't always straightforward).

As an aside : Keep all your shell scripts Bourne shell compatible (/bin/sh) if you really want to make sure they run everywhere. If you use bashisms or other shell built-ins not found in the base Bourne shell specification, you run the chance your script just won't work on some systems. Make use of awk/sed and other Unix utilities to replace the advanced shell built-ins whenever possible and avoid GNU extensions like the plague in scripts (but use them as much as you can when typing commands!).
 
Learning an "obscure" shell just to be different is the wrong approach.

I wouldn't say that was my approach at all. I looked at the various shells that were available and based my decision on what I read about them. From reading through the z shell manual it certainly has lots of useful features (particularly in the completion area) that bash supposedly is missing.

I wouldn't really call the zsh that obscure anyway. Even Apple bundle it with Mac OS X and they hardly do anything for the UNIX users.
 
tcsh all the way!

I am an experienced software research engineer, and I've been on Unix since 1990. Note that I said Unix, not Linux. I started out working on csh and then moved quickly to tcsh once I discovered it. Occasionally I write some bash scripts, but for day-to-day command-line usage, I use only tcsh.

Frankly, bash is primitive and repulsive. The only reason people use it is because they don't know any better.

bash --> Windows --> Honda Civic

tcsh --> Mac --> Fine German sports sedan


P.S. I also drive a fine German sports sedan.
 
tcsh all the way!

I am an experienced software research engineer, and I've been on Unix since 1990. Note that I said Unix, not Linux. I started out working on csh and then moved quickly to tcsh once I discovered it. Occasionally I write some bash scripts, but for day-to-day command-line usage, I use only tcsh.

Frankly, bash is primitive and repulsive. The only reason people use it is because they don't know any better.

bash --> Windows --> Honda Civic

tcsh --> Mac --> Fine German sports sedan


P.S. I also drive a fine German sports sedan.

Good old fashion trolling like this rarely ends up on this forum. Bravo! A mention of likely attributes of a bash user's mother would have really topped this with a cherry.

-Lee
 
I wouldn't really call the zsh that obscure anyway. Even Apple bundle it with Mac OS X and they hardly do anything for the UNIX users.

It's not on any of my HP-UX and Solaris servers. And if you think Apple hardly does a thing for the UNIX users, you've never used either HP-UX or Solaris. ;)

But since you seem to really want to be a master "zsh" user, I doubt anything we say will ever change your mind. Have fun doing whatever you want to do. Learning anything is never lost.
 
C shell && Korne

I use C shell (tcsh on Macs) as an interactive shell and (primarily) Korne for shell scripting, unless specifically requested to be scripted in another shell.

A few revisions ago on the Mac, the default shell was changed for some reason from tcsh to bash (easily reverted).

I work in a multi Unix environment (i.e. Solaris, Mac OS X, AIX, Irix, etc..), and the bash shell usually causes me the most problems, especially when coming from linux system admins. Linux doesn't have a real Borne shell, and /sbin/sh is usually symlink'ed to bash on said systems.

This frequently causes problems when linux admins write scripts that need to be ran on other Unix/Unix clone systems. Bash scripts, unless they are very simple/basic, are not backward compatible and will not run under a real Borne shell.
 
I use C shell (tcsh on Macs)

This frequently causes problems when linux admins write scripts that need to be ran on other Unix/Unix clone systems. Bash scripts, unless they are very simple/basic, are not backward compatible and will not run under a real Borne shell.

My SAP Basis friends have a few examples where C shell scripts exhibit the same behavior as tcsh and csh are not quite compatible. At least Bash is fully Bourne Shell compatible so if you stick to strick Bourne shell behavior, your scripts will run everywhere. With tcsh and csh it isn't quite so clear cut.

Heck they even asked me to install the real "csh" unto Linux... I told them to rework their scripts instead.
 
My SAP Basis friends have a few examples where C shell scripts exhibit the same behavior as tcsh and csh are not quite compatible.

I am sure that there are more than just a few. C shell has not been updated in over a decade. TCSH continues to be developed and refined today.

Please let me iterate my opening comment. I use C shell primarily as an interactive shell. Most of my shell scripting is done in Korn.


At least Bash is fully Bourne Shell compatible so if you stick to strick Bourne shell behavior, your scripts will run everywhere. With tcsh and csh it isn't quite so clear cut.

Odd, that's the very reason I avoid bash, lack of backward compatibility.

Heck they even asked me to install the real "csh" unto Linux... I told them to rework their scripts instead.

I know you are poking fun here, but you probably gave them some good advice. The shell scripts I have written in C shell were not very extensive. Korn is a much better choice for an all out massive shell script.

I don't know what you do in your line of work, but I do network and Unix administration. I am not going to write the next Word Perfect or Lotus 123. And even if I was, the one thing I know for certain is that the work wouldn't be done as a shell script.

Unix shells are, and should be a religious thing. You should have your favorite, depending on personal preferences and the requirements of your job. With that said, there is nothing wrong with knowing a little bit about most or all of them, and to understand their respective strengths and weaknesses.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.