Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
What are the fundamental differences between the mainstream *NIX shells?

If I write a shell script in bash, will it run in ksh as well?

if not, what are the differences?

share|improve this question

marked as duplicate by jasonwryan, Michael Mrozek Nov 2 '11 at 6:24

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

The Korn shell is ksh. csh is the C shell. Which one are you asking about? – Mat Nov 1 '11 at 7:33
up vote 5 down vote accepted

Depends on which specific commands/features you are using but generally no.

See http://en.wikipedia.org/wiki/Comparison_of_command_shells for a summary of differences between shells.

share|improve this answer

No. Both bash and ksh have custom specific extensions and behavior. If you want to write portable scripts, stick to POSIX syntax:



share|improve this answer

It's best to treat each separate shell as a separate programming language. Don't try to write polyglot shell scripts, it makes them unreadable and clunky. Instead, learn how to program in one shell and then be careful with always specify that shell as the script's interpreter in the hashbang on the first line.

Remember that the shell that your script is running in has nothing to do with the shell you're executing it from. Hence, you might be interacting with your UNIX system through csh while at the same time be writing all your shell scripts for ksh.

share|improve this answer
Slightly surprised about the down-vote. Please explain? – Kusalananda Nov 23 '11 at 10:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.