Types, shells, echoes and other phenomena ? [ was: Re: dapper sudo ]
Alan McKinnon
alan at linuxholdings.co.za
Wed Jul 5 13:27:16 UTC 2006
On Wed, 2006-07-05 at 20:21 +1000, Peter Garrett wrote:
> On Wed, 5 Jul 2006 18:55:11 +1000
> erik at dd.nec.com.au (Erik Christiansen) wrote:
>
> > erik at dvalin:~$ which echo
> > echo is a shell builtin
>
> Interesting.
>
> peter at prospero:~ $ which echo
> /bin/echo
> peter at prospero:~ $ which cd
> peter at prospero:~ $
>
> peter at prospero:~ $ type echo
> echo is a shell builtin
> peter at prospero:~ $ ls -l `which echo`
> -rwxr-xr-x 1 root root 16552 2006-05-06 03:50 /bin/echo
> peter at prospero:~ $ file `which echo`
> /bin/echo: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for
> GNU/Linux 2.2.0, dynamically linked (uses shared libs), for GNU/Linux
> 2.2.0, stripped
>
> peter at prospero:~ $ type cd
> cd is a shell builtin
>
> So... I'm more confused than I was now :) Are there two "echoes" ? ( An
> echo of an echo perhaps ?
Yes, there are two echoes
When you run 'echo' the builtin will run
If you run /bin/echo, the other one will run
'which echo' searches your $PATH looking for a command called echo
So, in almost all cases, the file you can see right in front of you is
not the one that get's run. Confusing isn't it? Welcome to The One True
Way - Unix. :-)
alan
More information about the ubuntu-users
mailing list