How to get current shell name (e.g. bash/zsh) on Linux

To get just the name of the shell, e.g. bash or zsh, use

example.sh
echo $SHELL | rev | cut -d/ -f1 | rev

Example:

example.sh
$ echo $SHELL | rev | cut -d/ -f1 | rev
bash

To get the full path of the current shell executable, use

example.sh
echo $SHELL

Example:

example.sh
$ echo $SHELL
/bin/zsh

 


Check out similar posts by category: Linux