Short Tip: determine current shell

To figure out the current shell you’re using, like bash, zsh or sh, just call ps -p $$:

ps -p $$ | tail -1 | awk '{print $NF}'

Pretty helpful if you’re playing with different shells at the same time.


4 thoughts on “Short Tip: determine current shell”

  1. The variable $SHELL contains the path to the current shell and $0 only represents the first argument given to a program (aka the name of the actual programm). To understand what I mean do the following:
    cd /home/liquidat
    echo $0

  2. $SHELL is just an enironment variable, it’s not always correct

    fess@McBean-1005% echo $SHELL
    fess@McBean-1006% /bin/bash
    McBean:~ fess$ echo $SHELL

    so where you think it would be bash it’s still zsh.

  3. $SHELL is the default shell. My question is how to determine the type of the shell in the script if the script is executable and invoked directly by the console (e.g., ./

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s