Bourne shell & Korn shell

Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command ..

$ echo $SHELL

yields me

/bin/sh

Does this tells me that I am in Bourne shell. If yes, how can i get into ksh??

$ exec ksh

??

Thanks

by typing: ksh
To be sure, you can always check with ps the pid returned by the command

 echo $$
1 Like

Just issue the command

$ksh
1 Like
[root@bt]-> bash
[root@bt]-> echo $0
bash
[root@bt]-> ksh
[root@bt]-> echo $0
ksh
[root@bt]-> sh
[root@bt]-> echo $0
sh
[root@bt]-> tcsh
root@bt:/tmp# echo $0
tcsh
root@bt:/tmp# csh
root@bt:/tmp# echo $0
csh

A brief comparison is present here. But not sure whether it will answer your question.

--ahamed

1 Like

Thanks all..

---------- Post updated at 12:03 PM ---------- Previous update was at 09:09 AM ----------

When i type the following command

$ ps
PID TTY         TIME CMD
  9536 pts/30      0:00 ksh
  9632 pts/30      0:00 bash
  9638 pts/30      0:00 ksh
 20891 pts/30      0:00 ksh
   281 pts/30      0:00 sh
 29441 pts/30      0:00 ps
 

What does it mean ? How do I know which shell I am in ? Any help would be really appreciated .

---------- Post updated at 12:10 PM ---------- Previous update was at 12:03 PM ----------

Got it.. Thanks vbe

ahamed101 is correct, $0 will return you the name of the shell or proc running,

I was getting mixed up by phone call on almost the same subject: "How can I find the PID of current shellscript (in order to kill it...), $$ will return the current shell or proc PID running - In your case its is almost the same...
Try this

n12:/home/vbe $  ps -ef|grep "$(echo $$)"|grep -v -e ps -e grep
     vbe  667702  970906   0   Oct 18 pts/24  0:00 /bin/sh /usr/bin/firefox 
     vbe  970906 1028296   1   Oct 12 pts/24  0:00 -ksh 
     vbe 1347730  970906   0   Oct 14 pts/24  2:25 dtterm 

You can always use it to create an alias and add it to your .kshrc file...

Or if you want to know the PID of a process you spawned in your current session, "$!" holds the PID of the last process.

Check the example below:

# nohup sleep 10 1>/dev/null 2>&1 &
[1] 5964
# echo $!
5964
# ps -ef | egrep "${!}" | grep -v -e ps -e grep
user     5964 PPID  0 14:34 pts/0    00:00:00 sleep 10