Why no output for 'which echo'?

Why no output for 'which echo'?

Post by <tolo.. » Sun, 29 Nov 1998 04:00:00



I fould something that got me curious about
Redhat Linux 4.2. If I do "which date", I get
the output /bin/date. If I do it for other binaries
I get the full pathname of the binary in my path.
However, if I do "which echo" I get nothing as
output. If I do "echo $LOGNAME" I get the proper
output. What's the deal?

Pierre

 
 
 

Why no output for 'which echo'?

Post by Stefan David » Sun, 29 Nov 1998 04:00:00



>I fould something that got me curious about
>Redhat Linux 4.2. If I do "which date", I get
>the output /bin/date. If I do it for other binaries
>I get the full pathname of the binary in my path.
>However, if I do "which echo" I get nothing as
>output. If I do "echo $LOGNAME" I get the proper
>output. What's the deal?

Echo is a built in for most modern shells:

hopf% which echo
echo: shell built-in command
hopf% echo $SHELL
/bin/zsh

If you ever accidently nuke your filesystem you might well appreciate this.

Stefan
--
perl -we '$_ = sub { print pack q(H2),(shift);return $_;}; $_->(q(4a))->
(q(75))->(q(73))->(q(74))->(q(20))->(q(41))->(q(6e))->(q(6f))->(q(74))->
(q(68))->(q(65))->(q(72))->(q(20))->(q(50))->(q(65))->(q(72))->(q(6c))->
(q(20))->(q(48))->(q(61))->(q(63))->(q(6b))->(q(65))->(q(72))->(q(0a));'

 
 
 

Why no output for 'which echo'?

Post by Brian McCaule » Sun, 29 Nov 1998 04:00:00



> I fould something that got me curious about
> Redhat Linux 4.2. If I do "which date", I get
> the output /bin/date. If I do it for other binaries
> I get the full pathname of the binary in my path.
> However, if I do "which echo" I get nothing as
> output.

$ type echo
echo is a shell builtin
$ type which
which is aliased to `type -p'
$ help type
type: type [-apt] name [name ...]
    For each NAME, indicate how it would be interpreted if used as a
    command name.

    If the -t option is used, returns a single word which is one of
    `alias', `keyword', `function', `builtin', `file' or `', if NAME is an
    alias, shell reserved word, shell function, shell builtin, disk file,
    or unfound, respectively.

    If the -p flag is used, either returns the name of the disk file
    that would be executed, or nothing if -t would not return `file'.

    If the -a flag is used, displays all of the places that contain an
    executable named `file'.  This includes aliases and functions, if and
    only if the -p flag is not also used.

    Type accepts -all, -path, and -type in place of -a, -p, and -t,
    respectively.

--

  .  _\\__[oo   faeces from    | Phones: +44 121 471 3789 (home)

 .  l___\\    /~~) /~~[  /   [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
  # ll  l\\  ~~~~ ~   ~ ~    ~ | http://www.wcl.bham.ac.uk/~bam/
 ###LL  LL\\ (Brian McCauley)  |

 
 
 

Why no output for 'which echo'?

Post by Ivo Naninc » Sun, 29 Nov 1998 04:00:00


'echo' is a built-in shell-command, and therefore 'which' doesn't find
it.


> I fould something that got me curious about
> Redhat Linux 4.2. If I do "which date", I get
> the output /bin/date. If I do it for other binaries
> I get the full pathname of the binary in my path.
> However, if I do "which echo" I get nothing as
> output. If I do "echo $LOGNAME" I get the proper
> output. What's the deal?

> Pierre

--
Best regards, and don't let the bits byte!
Ivo Naninck.
~
~
:wq!
 
 
 

Why no output for 'which echo'?

Post by Robert Hell » Sun, 29 Nov 1998 04:00:00



  In a message on Sat, 28 Nov 1998 07:42:37 GMT, wrote :

Quote:> I fould something that got me curious about
> Redhat Linux 4.2. If I do "which date", I get
> the output /bin/date. If I do it for other binaries
> I get the full pathname of the binary in my path.
> However, if I do "which echo" I get nothing as
> output. If I do "echo $LOGNAME" I get the proper
> output. What's the deal?

Echo is one of a set of "built-in" shell commands.  These commands
exist internally in the shell you are using.   Which is itself another
built-in command.  Yes, they also exist in /usr/bin or /bin as well,
since not all shells have them built-in and sometimes it is necessary to
use these commands outside of the context of a shell.

Quote:> Pierre

--
                                     \/

http://vis-www.cs.umass.edu/~heller  ||FidoNet:    1:321/153
http://netmar.com/mall/shops/heller  /\
 
 
 

Why no output for 'which echo'?

Post by Jim Nicholso » Mon, 30 Nov 1998 04:00:00


Pierre> I fould something that got me curious about Redhat Linux
Pierre> 4.2. If I do "which date", I get the output /bin/date. If I do
Pierre> it for other binaries I get the full pathname of the binary in
Pierre> my path.  However, if I do "which echo" I get nothing as
Pierre> output. If I do "echo $LOGNAME" I get the proper
Pierre> output. What's the deal?

echo is normally a built-in command of the shell and not a binary.  If
you are running bash, try

type echo

this will tell you if a command is a shell built-in, alias or binary
executable.

Jim

 
 
 

Why no output for 'which echo'?

Post by Tony Lawrenc » Tue, 01 Dec 1998 04:00:00



> 'echo' is a built-in shell-command, and therefore 'which' doesn't find
> > it.

> Also, 'which' can't find 'which' either (same reason) :-)  As a rule, if
> which doesn't work see if 'find' can find an executable; if not then try
> "info bash" or check your shell's documentation.

The ksh I'm using just now (not on Linux) will reply "echo" to
"whence echo", which I suppose is a little more enlightening
than a blank line.

--

SCO ACE
SCO articles, help, book reviews: http://www.aplawrence.com

 
 
 

Why no output for 'which echo'?

Post by Stev » Wed, 02 Dec 1998 04:00:00


if you use bash, try: 'help echo', echo is a bash command is compiled into bash
(or csh, tcsh, read their respective man pages). 'whereis' will search a
database
and that is why it is faster than 'find', however, you must run 'makewhatis' to
have
the command work.

Steve

 
 
 

1. Why does 'ls' give '/' as the output?

I've typed the following series of commands from window 1.

/usr/shailesh>mkdir tmpdir
/usr/shailesh>cd tmpdir
/usr/shailesh/tmpdir>touch a b c d
/usr/shailesh/tmpdir>ls
a   b   c   d

Now, i've gone into window 2 and did the following.

/usr/shailesh>rm -rf tmpdir

Now, i came back into window 1 and invoked the following command.
(In window 1 I am still in the "tmpdir" directory).

/usr/shailesh/tmpdir>ls
/

Why does 'ls' give '/' as the output?
Also,  if I invoke "ls -al", i still get the same output!
What  special  significance  does "/" have here? (Is it anything to do
with the "root" directory?).

And when I give the absolute directory:

/usr/shailesh/tmpdir>ls -la /eng1/swdev2/shailesh/tmpdir

will result in 'No such file or directory'.

I've contacted some local gurus here and what one of them suggested was :

The  shell  deals with such a situation by suggesting to change to the
root directory (as it 'for sure' knows that the root exists :-).

Thanks,
shailesh


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        Office                    |        Residence    
        ------                    |        ---------
Sequent Computer Systems Inc      | 16356 SW Estuary Drive,
15450 SW Koll Parkway,            | Apt #102,
Beaverton, OR - 97006             | Beaverton, OR - 97006
                                  |
ph : (503) 578 5706               | ph : (503) 629 9643
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

2. PCNFS and Solaris 2.3

3. Solaris 2.4 x86 and IRQ's

4. Why doesn't echo "text" 'command' "more text" work?

5. Lockups with XF86 3.1.2 and Video7.

6. "@home?" Definitely use a firewall !

7. echo '\a' does not work, Why?

8. (patch for Bash) '%NN' URL hexcode decoding for 'echo'

9. Changing Serial Nos using 'brand'

10. Use of 'eval' to evaluate an 'echo $variable' command...

11. Odd 'w', 'who' and 'tty' output