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 | revExample:
get_shell_name_example.sh
$ echo $SHELL | rev | cut -d/ -f1 | rev
bashGet the full path of the current shell executable
To get the full path of the current shell executable, use
print_shell_path.sh
echo $SHELLExample:
print_shell_path_example.sh
$ echo $SHELL
/bin/zshCheck 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