Which is better ksh or bash




















Free Software Development Course. Login details for this Free course will be emailed to you. Email ID. Contact No.

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 provides much more programming features and is superior in comparison to the Bash shell. Although Bash shell provides a lot of programming features, it is inferior to Korn shell. Korn shell uses the print command to print the output which is somehow better than echo in Bash.

Bash shell is new and has many new resources and is more popular in public as compared to Korn shell. There are almost no differences in the non-interactive parts of ksh and bash.

I write pretty generic stuff — runs in both. I never use them anyway. Both shells have the same commands to show history, re-run numbered commands, and so on. What happens to all the bad shots? How about getting the command right first time by some careful thought, to avoid doing any damage? Heck, you could even stuff it into a two line script and test it somewhere! As regards performance, any substantial processing should be done inside standard commands — awk, sed, grep, find etc.

If you are running enough raw shell commands to make performance a significant issue, then you are designing your solutions badly, or at least unsympathetically to Linux philosophy. No Account? Sign up. By signing in, you agree to our Terms of Use and Privacy Policy. Already have an account? Sign in. By signing up, you agree to our Terms of Use and Privacy Policy.

Enter the email address associated with your account. We'll send a magic link to your inbox. Email Address. All Sign in options. Enter a Email Address. Choose your interests Get the latest news, expert insights and market research, sent straight to your inbox. Newsletter Topics Select minimum 1 topic. Tags: Shell Script. If you're not sure if that command was the one you want, use! Then if it is what you want, a simple up arrow-enter, or just!! Show 11 more comments.

If you're doing only minimum-common-denominator ksh, I'd agree. Genuine David Korn ksh93, on the other hand, has compelling advantages for scripting: Speed that puts it near awk for text processing; native floating point math; namevars and associative arrays even on systems not running the latest release; etc. I'm a korn-shell veteran, so know that I speak from that perspective. If you want portability use at least both.

And make sure you have a good test suite. There are many subtle differences between shells. Shell programming is like swimming in uncharted waters, or worse. Henk Langeveld Henk Langeveld 7, 40 40 silver badges 54 54 bronze badges. Re: your read difference, in noninteractive mode that's actually configurable for modern bash -- see the lastpipe option.

CharlesDuffy correct, and it was available when I wrote this - however, it's still not default behaviour - you need bash 4. Shopt options are awkward, as their setting can actually trigger syntax errors. Kristian Kristian 2 2 bronze badges. HP-UX provides sh, csh, and ksh as default shells. In But, given the amount of That's how I have mine set. Jon Ericson Jon Ericson For one thing, bash has tab completion. This alone is enough to make me prefer it over ksh. Allen Allen 4, 21 21 silver badges 30 30 bronze badges.

Source: kornshell. Hank Gay Hank Gay This takes a lot of people by surpise when their "valid" bash commands are rejected by! Incident Incident 4 4 silver badges 7 7 bronze badges.

As of this answer's writing, ksh93 arguably had more bells and whistles from a programming perspective associative arrays and namevars come first to mind -- though that's changed in the intervening eight years. It still has floating-point math, which bash continues to lack.

MeaCulpa MeaCulpa 6 6 silver badges 14 14 bronze badges. I can not really address the actual programming differences between the shells, unfortunately. If you are planning to distribute scripts use posix-sh. Bash is a good shell, and the default on linux. Older Unix flavors tend to have sh, ksh, and csh. In a production environment, it can be difficult to get permission or forgiveness for installing the shell of your choice on all the systems.

Even when you tell it specifically not to, it usually lets you anyway. The vi mode in Bash is also pretty poorly implemented. I would keen to see some real life examples involving difference in dealing with arrays, history, printing and loops — but no luck. My score — B minus. Yeah, about that. Korn shell will let you do this, but bash can be problematic with this. In other words, with korn shell you can write an if statement like this:.

In older versions of bash you have to keep the number of conditionals in the if statement to two or less. That would look like this:. The workaround is to use nested if statements like this:.

In this respect, Korn shell has an advantage over bash since it is more friendly to multiple conditionals in an if statement. If you are used to the interactive!! The syntax for arrays are different. Korn has the feel of the old Unix hard-wired, serial terminal days. Too much work. It took about 35 scripts to do so. It logged incoming and outgoing files to a database.



0コメント

  • 1000 / 1000