Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I actually had to look up some features between various shells recently that I don't frequently use and ran into this chart, it might answer some of your questions at least on the technical aspects.
There are open source versions of ksh. You can run it on Linux (we do). There was an older ksh for OSS called pdksh that acted somewhat differently than the newer ksh and that may be why folks didn't like it.
There are several differences - bash has most of what ksh does and then some extra stuff. A script written to run in ksh would likely run in bash just fine. A lot of the differences deal with math, variables, arrays, functions etc... - bash just seems to have a hell of lot more of this than ksh
One thing that originally kept me from using bash over ksh was that I liked the vi style editing that ksh used by default but not bash. However, you can type "set -o vi" in bash to get that same functionality.
Odd, it opens from my net host, work machine, and home machine. Not sure what problem it might be having.
It works for me too. Funny - I was going to provide the link and others but they are 7 years old or more. I have to believe there have been other enhancements to both ksh and bash since then.
A script written to run in ksh would likely run in bash just fine. A lot of the differences deal with math, variables, arrays, functions etc... - bash just seems to have a hell of lot more of this than ksh
bash isn't always the winner. ksh has some nice useful variable typing that bash doesn't.
... and you don't have to keep reapplying the translation to ensure the value is lowercase should the value ever be changed. Very Useful for when dealing with user input.
I also prefer the ksh math syntax of
Code:
let a=b+c
rather than bash's more unwieldy;
Code:
a=$(( b+c ))
... but that's just a minor style thing.
The biggest difference that tends to catch people out though is this one...
... Oi! bash!... where'd my variable go?
What makes this one particularly bad is that the bash code looks like it ought to work. It's only when you understand the underlying semantics of how bash deals with pipelines that you realise why it doesn't.
Because bash runs a pipeline in a sub-shell, you actually have to do it like this
Code:
read variable < <(echo wibble)
echo $variable
I prefer ksh in many ways, but I'm sure part of that is because it's what I'm used to being an old timer.
Distribution: CentOS, RHEL, Solaris 10, AIX, HP-UX
Posts: 731
Rep:
Hi,
one reason for using ksh for scripting is, this shell is available on nearly all existing flavours of *nix. Bash is not installed by default on all *nix.
Don't get me wrong. I've liked ksh ever since I first saw back in the early 90s. I was just saying there's a hell of a lot added to bash that doesn't exist in ksh or the posix sh.
I also agree that ksh is available on multiple platforms by default but bash would have to be specifically added. On the flip side though, most Linux distros come with bash and you have to add ksh if you want it.
For most of my scripting what I learned with ksh is sufficient so I do it that way (most of my math I do by piping to bc -l which works in both ksh and bash). However, I've seen enough other examples to let me know that bash can do some fairly sophisticated things of its own that ksh doesn't. The examples show indicate different ways of doing things in bash than ksh but didn't show anything that could be done in ksh that can't be done in bash in some way.
one reason for using ksh for scripting is, this shell is available on nearly all existing flavours of *nix. Bash is not installed by default on all *nix.
but ksh is not installed by default on all linux at least..
Me I find bash's way of handling arrays easier and also the SIGCHILD signal (not sure if its there in KSH) is also important.
Last edited by konsolebox; 02-26-2010 at 05:28 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.