[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]


    Search the Q&A Archives


...find the name of the current shell that I am...

<< Back to: Unix - Frequently Asked Questions (1/7) [Frequent posting]

Question by mulla
Submitted on 10/27/2003
Related FAQ: Unix - Frequently Asked Questions (1/7) [Frequent posting]
Rating: Rate this question: Vote
How do I find the name of the current shell that I am working on(Whether csh or ksh or bsh)? Are there any specific commands to find out?


Answer by Thierry
Submitted on 11/12/2003
Rating:  Rate this answer: Vote
Just type in the ps command.

That should do it!! :o)

 

Answer by Jayakhanna
Submitted on 12/4/2003
Rating:  Rate this answer: Vote
ps | grep `echo $$` | awk '{ print $4 }'

This would do as ps will list all the shell, echo $$ will tell the current shells process id and then we can print the current shell after doing grep

 

Answer by Thayir
Submitted on 12/8/2003
Rating:  Rate this answer: Vote
echo $SHELL

 

Answer by Jayakhanna
Submitted on 12/12/2003
Rating:  Rate this answer: Vote
echo $SHELL will only tell the initial shell when you do ksh/csh after that it will still show the intial shell so this is not correct one.

Regards
JK

 

Answer by cong
Submitted on 1/1/2004
Rating:  Rate this answer: Vote
if i want to put this in aliases file how can it be done?

lets say:

alias sh `ps | grep "^ *$$" | awk '{ print $4 }'`

i kept getting error, either grep error or awk error, i think the problem is the order of `""''`

 

Answer by Robert Hunter
Submitted on 3/16/2004
Rating:  Rate this answer: Vote
If I were to do this, I'd use:

ps $$

And to alias it, as suggested above, I'd use:

alias currentshell='ps --no-headers --format comm $$'

I find it a good idea to use the long-format options for scripts and aliases -- you only have to type them once, and it makes what they do a whole lot clearer when you look at them later.

 

Answer by Ravikumar R
Submitted on 8/18/2004
Rating: Not yet rated Rate this answer: Vote
ps | grep "$$"

 

Answer by Jay Padmanathan
Submitted on 12/9/2005
Rating: Not yet rated Rate this answer: Vote
In solaris you would say:

ps -o comm= -p $$

The space after comm= is necessary to suppress unwanted headers

 

Answer by ParseANull
Submitted on 5/16/2006
Rating: Not yet rated Rate this answer: Vote
echo $0

 

Your answer will be published for anyone to see and rate.  Your answer will not be displayed immediately.  If you'd like to get expert points and benefit from positive ratings, please create a new account or login into an existing account below.


Your name or nickname:
If you'd like to create a new account or access your existing account, put in your password here:
Your answer:

FAQS.ORG reserves the right to edit your answer as to improve its clarity.  By submitting your answer you authorize FAQS.ORG to publish your answer on the WWW without any restrictions. You agree to hold harmless and indemnify FAQS.ORG against any claims, costs, or damages resulting from publishing your answer.

 

FAQS.ORG makes no guarantees as to the accuracy of the posts. Each post is the personal opinion of the poster. These posts are not intended to substitute for medical, tax, legal, investment, accounting, or other professional advice. FAQS.ORG does not endorse any opinion or any product or service mentioned mentioned in these posts.

 

<< Back to: Unix - Frequently Asked Questions (1/7) [Frequent posting]


[ Home  |  FAQ-Related Q&As  |  General Q&As  |  Answered Questions ]

© 2008 FAQS.ORG. All rights reserved.