$ which echo echo: shell built-in command. $ which ls /bin/ls $ which cat /bin/cat
Why is echo not an independent utility like
cat etc? Why is it shell specific? Any good reasons?
There are two classes of builtins:
Unix systems have always included separate executables for commands in that second class. These separate executables are still available on every Unixy system I've used, even though they're also built into every shell you're likely to use. (POSIX actually requires that these executables be present.)
I'm pretty sure this isn't a Berkeley CSRG innovation that AT&T brought back home. 4.3BSD came out the same year as SVR3, 1986. (SVR3.1 came out in 1987.) If you look at 4.3BSD's sh.1 manpage, you see that
It is possible that
According to the Bash Reference Manual, it's about convenience.
The Advanced Bash Scripting Guide has a more detailed explanation:
Also note that
There is a third reason for some commands to be built-in: They can be used when running external commands is impossible.
Sometimes a system becomes so broken that the
Another (more important!) example is
Although most shells include a built-in
It sounds like you don't have GNU Coreutils installed (most linux-based desktop & server OS have it installed by default, but embeded linux or other UNIX might use alternative collections of shell utilities instead).
BTW: if you look at Busybox, you'll see that
To complement bhm's answer, let's say