I was playing around with the type
and which
commands and I discovered something strange.
type
either returns the path or says that a command is a Bash built in.
which
either returns the path or nothing for built ins such as exit
or type
What is strange is that type echo
says that echo is a built in as I expected.
But which echo
gives /bin/echo as the path to the echo executable. This doesn't seem to happen for any other built in commands.
I am wondering what the different between the two is, which one Bash chooses to execute in scripts and on the command line, and what the story behind the two echos is.
My system is Ubuntu Desktop 12.04
echo
builtin, see Why is echo a shell built in command?. Regardingwhich
, see Why not use “which”? What to use then? – Gilles 'SO- stop being evil' Oct 12 '14 at 22:31