Thursday, October 18, 2012

How to find the current shell in UNIX Solaris Linux?

This method works perfectly in any shell.

NOTE: $$ holds the process id of current shell.

[penguin@cheetah:/home/penguin]#ps | grep -i `echo $$`
 18530             0:00 ksh

[penguin@cheetah:/home/penguin]#bash
bash-3.00$ ps | grep -i `echo $$`
 18574 pts/196     0:00 bash

bash-3.00$ csh
cheetah% ps | grep -i `echo $$`
 18578 pts/196     0:00 csh

cheetah% tcsh
> ps | grep -i `echo $$`
 18590             0:00 tcsh


5 comments:

SUJAY said...

To find the current shell and display the shell name alone:

[penguin@cheetah:/home/penguin]# ps | grep `echo $$` | awk '{print $NF}'
ksh

Anonymous said...
This comment has been removed by the author.
Anonymous said...

http://2.bp.blogspot.com/-xh3sW85RWS4/UJCVGRQ7zzI/AAAAAAAAOKQ/ltY9quzfpZY/s1600/10.jpg

Rajesh said...

This is the information that I was looking for. Thanks for the efforts you put to gather such a nice content and posted here.
Oracle Fusion HCM Training Institutes in Hyderabad

Patrick Co Eban said...


Networking Projects for Final Year CSE Students


The IEEE Network projects Networking Projects for Final Year CSE Students has direct impact on undergraduate and graduate student education and training. Final Year Engineering Students who are software developers can structure a project around building a network firewall application Final Year Project Centers in Chennai

JavaScript Training in Chennai

JavaScript Training in Chennai