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?
Looking to understand from the perspective of a user, rather than purely scripting.
Bash and KSH are both Bourne-compatible shells. Since they share common features, they can be used interchangeably.
Korn shell provides much better performance than Bash shell when dealing with the execution of scripts and commands. Bash shell provides decent performance when it comes to executing commands and scripts. Korn shell interpreter is located at /bin/ksh. Bash shell interpreter is located at /bin/bash.
The ksh command invokes the Korn shell, which is an interactive command interpreter and a command programming language. The shell carries out commands either interactively from a terminal keyboard or from a file.
Korn shell uses the print command to print the message in the terminal. Bash shell uses the echo command to print the message in the terminal. Korn shell has better support to loop handling as compared to the Bash shell. The Korn shell is developed by David Korn and it's older than the Bash shell.
The difference between Kornshell and Bash are minimal. There are certain advantages one has over the other, but the differences are tiny:
print
command which is way better than the echo
command.r
history command that allows me to quickly rerun older commands.cd old new
which replaces old
with new
in your directory and CDs over there. It's convenient when you have are in a directory called /foo/bar/barfoo/one/bar/bar/foo/bar
and you need to cd to /foo/bar/barfoo/two/bar/bar/foo/bar
In Kornshell, you can simply do cd one two
and be done with it. In BASH, you'd have to cd ../../../../../two/bar/bar/foo/bar
.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.
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!.
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.
BASH is simply the shell of choice now, so if you've got to learn something, might as well go with what is popular.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With