如何在 Linux 上获取当前 shell 名称(例如 bash/zsh)
仅 shell 名称
要仅获取 shell 的名称,例如 bash 或 zsh,使用
get_shell_name.sh
echo $SHELL | rev | cut -d/ -f1 | rev示例:
get_shell_name_example.sh
$ echo $SHELL | rev | cut -d/ -f1 | rev
bash获取当前 shell 可执行文件的完整路径
要获取当前 shell 可执行文件的完整路径,使用
print_shell_path.sh
echo $SHELL示例:
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