LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 11-20-2015, 03:13 AM   #1
Sathishtvs
LQ Newbie
 
Registered: Nov 2015
Posts: 1

Rep: Reputation: Disabled
Difference b/w sh, ksh and bash and it's uses


Dear Linux Genius,

I'm new to Shell scripting and i want to know the difference b/w sh, ksh and bash shell scripting and also want to know when to use these shell scripting techniques.
Can you please suggest me go further. If possible pls share one example it will help me for better understanding.

Thanks in Advance.
Sathish
 
Old 11-20-2015, 03:29 AM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,687

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
sh is the original UNIX shell. Also known as Bourne shell after its original designer. See also http://mywiki.wooledge.org/BourneShell.
ksh is the Korn shell, also named after its original designer. It adds numerous features to sh, in particular with regards to interactive use. See http://mywiki.wooledge.org/KornShell
There is also a POSIX shell which attempts to standardize shell behaviour.
Bash ("bourne-again shell") is the standard Linux shell. It's POSIX-compliant but has many additional features. See http://mywiki.wooledge.org/BashGuide.

Wikipedia also contains a lot of info about the shell.

For shell scripts, use sh or POSIX shell if you need maximum compatibility, and bash if not. Bash has many features that make it easier to write and read scripts. For example, this original Bourne shell code:
Code:
if [ expr "$a" + "$b" -gt 13 ]
then ....
can be written as follows in bash:
Code:
if (( a+b>13 ))
then ....
On many (most? all?) distros /bin/sh is a symbolic link to /bin/bash; you need to check if the Bourne shell exists at all.
Just checked - the standard Centos 7 repositories don't appear to have the Bourne or Posix shell. ksh is available though.

Last edited by berndbausch; 11-20-2015 at 03:30 AM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Whats the difference between ksh and bash? dev_d Linux - Newbie 11 02-26-2010 05:17 PM
Bash vs ksh Nickbrandson Linux - Newbie 7 04-23-2008 07:40 PM
the difference ksh wanghao Linux - Server 2 03-19-2008 07:18 AM
How to switch from BASH to KSH? tejpatil Linux - Software 13 06-14-2007 03:03 PM
bash or ksh noir911 *BSD 5 05-10-2007 12:08 PM


All times are GMT -5. The time now is 12:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration