<p>I am not new to *nix, however lately I have been spending a lot of time at the prompt. My question is what are the advantages of using KornShell (ksh) or Bash Shell? Where are the pitfalls of using one over the other? </p>

<p>Looking to understand from the perspective of a user, rather than purely scripting.</p>

[{'answer_id': 74868, 'author': 'foxxtrot', 'author_id': 10369, 'author_profile': 'https://Stackoverflow.com/users/10369', 'pm_score': -1, 'selected': False, 'text': "<p>Bash is the benchmark, but that's mostly because you can be reasonably sure it's installed on every *nix out there. If you're planning to distribute the scripts, use Bash.</p>\n\n<p>I can not really address the actual programming differences between the shells, unfortunately.</p>\n"}, {'answer_id': 74872, 'author': 'Allen', 'author_id': 6043, 'author_profile': 'https://Stackoverflow.com/users/6043', 'pm_score': 2, 'selected': False, 'text': '<p>For one thing, bash has tab completion. This alone is enough to make me prefer it over ksh.</p>\n\n<p><a href="http://zsh.org/" rel="nofollow noreferrer">Z shell</a> has a good combination of ksh\'s unique features with the nice things that bash provides, plus a lot more stuff on top of that. </p>\n'}, {'answer_id': 74936, 'author': 'Hank Gay', 'author_id': 4203, 'author_profile': 'https://Stackoverflow.com/users/4203', 'pm_score': 2, 'selected': False, 'text': "<p>@foxxtrot</p>\n\n<p>Actually, the standard shell is Bourne shell (<code>sh</code>). <code>/bin/sh</code> on Linux is actually <code>bash</code>, but if you're aiming for cross-platform scripts, you're better off sticking to features of the original Bourne shell or writing it in something like <code>perl</code>.</p>\n"}, {'answer_id': 74992, 'author': 'Chris AtLee', 'author_id': 4558, 'author_profile': 'https://Stackoverflow.com/users/4558', 'pm_score': 3, 'selected': False, 'text': '<p>I don\'t have experience with ksh, but I have used both bash and zsh.  I prefer zsh over bash because of its support for very powerful file globbing, variable expansion modifiers, and faster tab completion.</p>\n\n<p>Here\'s a quick intro: <a href="http://friedcpu.wordpress.com/2007/07/24/zsh-the-last-shell-youll-ever-need/" rel="noreferrer">http://friedcpu.wordpress.com/2007/07/24/zsh-the-last-shell-youll-ever-need/</a></p>\n'}, {'answer_id': 75092, 'author': 'Incident', 'author_id': 11613, 'author_profile': 'https://Stackoverflow.com/users/11613', 'pm_score': 2, 'selected': False, 'text': "<p>My answer would be 'pick one and learn how to use it'. They're both decent shells; bash probably has more bells and whistles, but they both have the basic features you'll want. bash is more universally available these days. If you're using Linux all the time, just stick with it.</p>\n\n<p>If you're programming, trying to stick to plain 'sh' for portability is good practice, but then with bash available so widely these days that bit of advice is probably a bit old-fashioned.</p>\n\n<p>Learn how to use completion and your shell history; read the manpage occasionally and try to learn a few new things.</p>\n"}, {'answer_id': 75114, 'author': 'Kristian', 'author_id': 12911, 'author_profile': 'https://Stackoverflow.com/users/12911', 'pm_score': 3, 'selected': False, 'text': '<p>This is a bit of a Unix vs Linux battle. Most if not all Linux distributions have bash installed and ksh optional. Most Unix systems, like Solaris, AIX and HPUX have ksh as default.</p>\n\n<p>Personally I always use ksh, I love the vi completion and I pretty much use Solaris for everything.</p>\n'}, {'answer_id': 75187, 'author': 'Matthieu', 'author_id': 9310, 'author_profile': 'https://Stackoverflow.com/users/9310', 'pm_score': -1, 'selected': False, 'text': '<p><em>Bash</em> is the standard for Linux.<br>\nMy experience is that it is easier to find help for bash than for ksh or csh.</p>\n'}, {'answer_id': 76773, 'author': 'Jon Ericson', 'author_id': 1438, 'author_profile': 'https://Stackoverflow.com/users/1438', 'pm_score': 3, 'selected': False, 'text': '<p>For scripts, I always use <em>ksh</em> because it smooths over <a href="https://stackoverflow.com/questions/2732/shell-scripting-input-redirection-oddities#12412">gotchas</a>.</p>\n\n<p>But I find <em>bash</em> more comfortable for interactive use.  For me the <em>emacs</em> key bindings and tab completion are the main benefits.  But that\'s mostly force of habit, not any technical issue with <em>ksh</em>.</p>\n'}, {'answer_id': 76829, 'author': 'j.e.hahn', 'author_id': 13735, 'author_profile': 'https://Stackoverflow.com/users/13735', 'pm_score': 7, 'selected': True, 'text': '<p>Bash. </p>\n\n<p>The various UNIX and Linux implementations have various different source level implementations of ksh, some of which are real ksh, some of which are pdksh implementations and some of which are just symlinks to some other shell that has a "ksh" personality. This can lead to weird differences in execution behavior.</p>\n\n<p>At least with bash you can be sure that it\'s a single code base, and all you need worry about is what (usually minimum) version of bash is installed. Having done a lot of scripting on pretty much every modern (and not-so-modern) UNIX, programming to bash is more reliably consistent in my experience.</p>\n'}, {'answer_id': 5525644, 'author': 'Henk Langeveld', 'author_id': 667820, 'author_profile': 'https://Stackoverflow.com/users/667820', 'pm_score': 5, 'selected': False, 'text': "<p>I'm a korn-shell veteran, so know that I speak from that perspective.</p>\n\n<p>However, I have been comfortable with Bourne shell, ksh88, and ksh93, and for the most I know which features are supported in which. (I should skip ksh88 here, as it's not widely distributed anymore.)</p>\n\n<p>For interactive use, take whatever fits your need. Experiment. I like being able to use the same shell for interactive use and for programming.</p>\n\n<p>I went from ksh88 on SVR2 to tcsh, to ksh88sun (which added significant internationalisation support) and ksh93. I tried bash, and hated it because\nit flattened my history. Then I discovered <code>shopt -s lithist</code> and all was well.\n(The <code>lithist</code> option assures that newlines are preserved in your command\nhistory.)</p>\n\n<p>For shell programming, I'd seriously recommend ksh93 if you want a consistent programming language, good POSIX conformance, and good performance, as many common unix commands can be available as builtin functions.  </p>\n\n<p>If you want portability use at least both. And make sure you have a good test suite.</p>\n\n<p>There are many subtle differences between shells.  Consider for example reading from a pipe:</p>\n\n<pre><code>b=42 &amp;&amp; echo one two three four |\n    read a b junk &amp;&amp; echo $b\n</code></pre>\n\n<p>This will produce different results in different shells. The korn-shell runs pipelines from back to front; the last element in the pipeline runs in the current process.  Bash did not support this useful behaviour until v4.x, and even then, it's not the default.</p>\n\n<p>Another example illustrating consistency: The <code>echo</code> command itself, which was made obsolete by the split between BSD and SYSV unix, and each introduced their own convention for not printing newlines (and other behaviour).  The result of this can still be seen in many 'configure' scripts.</p>\n\n<p>Ksh took a radical approach to that - and introduced the <code>print</code> command, which actually supports both methods (the <code>-n</code> option from BSD, and the trailing <code>\\c</code> special character from SYSV)</p>\n\n<p>However, for serious systems programming I'd recommend something other than a shell, like python, perl.  Or take it a step further, and use a platform like puppet - which allows you to watch and correct the state of whole clusters of systems, with good auditing.</p>\n\n<p>Shell programming is like swimming in uncharted waters, or worse.</p>\n\n<p>Programming in any language requires familiarity with its syntax, its interfaces and behaviour.  Shell programming isn't any different.</p>\n\n\n"}, {'answer_id': 6985612, 'author': 'David W.', 'author_id': 368630, 'author_profile': 'https://Stackoverflow.com/users/368630', 'pm_score': 7, 'selected': False, 'text': "<p>The difference between Kornshell and Bash are minimal. There are certain advantages one has over the other, but the differences are tiny:</p>\n\n<ul>\n<li>BASH is much easier to set a prompt that displays the current directory. To do the same in Kornshell is hackish.</li>\n<li>Kornshell has associative arrays and BASH doesn't. Now, the last time I used Associative arrays was... Let me think... Never.</li>\n<li>Kornshell handles loop syntax a bit better. You can usually set a value in a Kornshell loop and have it available after the loop.</li>\n<li>Bash handles getting exit codes from pipes in a cleaner way.</li>\n<li>Kornshell has the <code>print</code> command which is way better than the <code>echo</code> command.</li>\n<li>Bash has tab completions. In older versions</li>\n<li>Kornshell has the <code>r</code> history command that allows me to quickly rerun older commands.</li>\n<li>Kornshell has the syntax <code>cd old new</code> which replaces <code>old</code> with <code>new</code> in your directory and CDs over there. It's convenient when you have are in a directory called <code>/foo/bar/barfoo/one/bar/bar/foo/bar</code> and you need to cd to <code>/foo/bar/barfoo/two/bar/bar/foo/bar</code> In Kornshell, you can simply do <code>cd one two</code> and be done with it. In BASH, you'd have to <code>cd ../../../../../two/bar/bar/foo/bar</code>.</li>\n</ul>\n\n<p>I'm an old Kornshell guy because I learned Unix in the 1990s, and that was the shell of choice back then. I can use Bash, but I get frustrated by it at times because in habit I use some minor feature that Kornshell has that BASH doesn't and it doesn't work. So, whenever possible, I set Kornshell as my default.</p>\n\n<p>However, I am going to tell you to learn BASH. Bash is now implemented on most Unix systems as well as on Linux, and there are simply more resources available for learning BASH and getting help than Kornshell. If you need to do something exotic in BASH, you can go on Stackoverflow, post your question, and you'll get a dozen answers in a few minutes -- and some of them will even be correct!.</p>\n\n<p>If you have a Kornshell question and post it on Stackoverflow, you'll have to wait for some old past their prime hacker like me wake up from his nap before you get an answer. And, forget getting any response if they're serving pudding up in the old age home that day.</p>\n\n<p>BASH is simply the shell of choice now, so if you've got to learn something, might as well go with what is popular.</p>\n"}, {'answer_id': 7279284, 'author': 'MeaCulpa', 'author_id': 846050, 'author_profile': 'https://Stackoverflow.com/users/846050', 'pm_score': 2, 'selected': False, 'text': "<p>Available in most UNIX system, ksh is standard-comliant, clearly designed, well-rounded.\nI think books,helps in ksh is enough and clear, especially the O'Reilly book.\nBash is a mass. I keep it as root login shell for Linux at home only.</p>\n\n<p>For interactive use, I prefer zsh on Linux/UNIX. I run scripts in zsh, but I'll test most of my scripts, functions in AIX ksh though.</p>\n"}]
['https://Stackoverflow.com/questions/74844', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/13158/']