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 Kumar 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 a blog administrator.
Anonymous said...

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

calfre search 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

shivani said...

A befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind fact and sensible. The substance of information is instructive
Oracle Fusion Financials Online Training
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training