如何检查变量或命令是来自bash还是unix?

ath*_*hos 1 unix bash

在bash中,人们可以使用

env
printev
Run Code Online (Sandbox Code Playgroud)

打印环境(全局)变量,或使用

set
Run Code Online (Sandbox Code Playgroud)

打印局部变量.但是,如果这个变量来自bash脚本环境,或者来自unix操作系统,怎么可能知道呢?

与命令类似的问题,怎么会知道

ls
grep
od
Run Code Online (Sandbox Code Playgroud)

等,是来自Ubuntu OS还是来自bash环境?

cni*_*tar 6

你可以使用type内置.

[cnicutar@fresh ~]$ type ps
ps is /bin/ps
[cnicutar@fresh ~]$ type type
type is a shell builtin
[cnicutar@fresh ~]$ type ls
ls is aliased to `ls --color=auto'
[cnicutar@fresh ~]$ type if
if is a shell keyword
Run Code Online (Sandbox Code Playgroud)