So I was reading the book The Linux Command Line, and it says that commands are of four types:
(1) executable programs
(2) shell builtins
(3) shell functions (shell scripts)
(4) aliases
Then it says that in order to identify the type of a command, you can use the type command.
However, I noticed that the type command fails to distinguish between a shell function (shell script) and an executable command.
For example:
type cp
(will output: cp is /bin/cp)
type bzexe
(will output: bzexe is /bin/bzexe)
However, we all know that cp is an executable program and bzexe is a shell script.
So my question is now: what command can we use to differentiate between those two?
I do know about the file command, and it works fine. Is that the only solution?
bash-completionin your interactive shells, you can see an example of a shell function by doingtype -a _pids. Running shell scripts from the shell isn't special. You shouldn't normally try tosourcethem instead of running them normally. When you run them normally, it doesn't matter what language they're written in. But yes,fileis a good way to find out what kind of file something is if you're curious.