How to get current shell name (e.g. bash/zsh) on Linux
Just the name of the shell
To get just the name of the shell, e.g. bash
or zsh
, use
get_shell_name.sh
echo $SHELL | rev | cut -d/ -f1 | rev
Example:
get_shell_name_example.sh
$ echo $SHELL | rev | cut -d/ -f1 | rev
bash
Get the full path of the current shell executable
To get the full path of the current shell executable, use
print_shell_path.sh
echo $SHELL
Example:
print_shell_path_example.sh
$ echo $SHELL
/bin/zsh
Check out similar posts by category:
Linux
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow