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

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

Post by Shailesh K Basa » Thu, 20 Apr 1995 04:00:00



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
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

 
 
 

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

Post by Edmund Roche-Kel » Fri, 21 Apr 1995 04:00:00



Quote:>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?

I guess it's just confused. You are trying to list something
when you're nowhere on the directory tree. On our system, ls does
this...

Script started on Thu Apr 20 19:20:01 1995

gosset-7:20pm-~
gosset-7:20pm-~ mkdir temp
gosset-7:20pm-~ cd temp
gosset-7:20pm-~/temp touch a b c d
gosset-7:20pm-~/temp rm -fr ~/temp
gosset-7:20pm-~/temp ls
ls: .: Stale NFS file handle
gosset-7:20pm-~/temp pwd
/u/maths/4/hades/temp
gosset-7:20pm-~/temp cd
gosset-7:20pm-~ exit

script done on Thu Apr 20 19:21:02 1995
--

<a href="http://www.maths.tcd.ie/~hades/hades.html">My homepage</a>

 
 
 

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


I think I figured out the problem.  Thanks for all your responses.

I'm  using  Korn  shell  on  UNIX  System  V  Release 4.0 on Sequent's
Symmetry Machines.

Assume i performed all the steps till removal of the "tmpdir".

/usr/shailesh>which ls
/bin/ls                    # I've *not* aliased "ls" to some other file
                           # in my PATH. So, which is expected to give this output.

/usr/shailesh>whence -v ls
ls is an alias for ls -FC  # Generally ls="ls -FC" ll="ls -la" are
                           # the default aliases found in .kshrc ($ENV).

/usr/shailesh/tmpdir>ls
/

/usr/shailesh/tmpdir>/bin/ls
/usr/shailesh/tmpdir>  -----> It immediately gave me the prompt.

/usr/shailesh/tmpdir>/bin/ls -l
drwxr-xr-x    0 shailesh contract       0 Apr 21 10:14
In the last column "nothing" is printed.

And now to figure it out :

The  -F  option  in  ls : Puts a slash (/) after each filename if that
file is a directory.

So,  here  when I type "ls -FC", it is putting a slash after "nothing"
and hence it is giving the output as "/".

Though  "/bin/ls"  doesn't  give  any  output  like  "No  such file or
directory", it gives "nothing" which is better than what we thought as
might-be-root!!

thanks and regards,
shailesh

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ph #s: (O) 503 - 578 - 5706
       (R) 503 - 629 - 9643
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

2. Linux ISP hardware

3. sed -e 's/\'a\'/\';\'/' ?

4. Got linux in, now what?

5. Can 'require' override 'allow'/'deny' (Apache)

6. Computer gets stuck at boot up, only "LI" of the LILO prompt shows

7. why would 'cp' or 'ls -al' command hangs on Solaris 2.7 ?

8. Bad Header

9. 64k files in dir - 'ls' slow but 'strace ls' fast?

10. 'ls -e' vs 'ls -l'

11. 'IRQ timeout' message and 'DMA disabled' with 'ls -l'

12. sed and '/' to '\/' conversion.

13. replacing '/' with '\\'