Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 09 Nov 2000 10:11:01 +0100 (CET)
From:      Micke Josefsson <mj@isy.liu.se>
To:        freebsd-questions@freebsd.org
Subject:   A weird inconsistency: ls vs. cp
Message-ID:  <XFMail.001109101101.mj@isy.liu.se>

next in thread | raw e-mail | index | archive | help
This is an inconsistency that has bugged for a long time. It seems to be the
same on every system I have tried: BSD/Linux/Solaris. I have to live with it but
I cannot for my life understand why it is there!


There is a difference between a directory name with and without a slash -
sometimes.

An example.

#pwd
#/usr/home/mj/tmp
#du
10        ./usr
20        ./usr/local
#        

Now these two cp's do not do the same thing:

#cp -r usr  /  (copies 'local' above to /usr/local)
#cp -r usr/ /  (copies 'local' above to /local)

So there is a difference between usr and usr/, right?
Appending a / means to contents of the directory?

No! Not so when trying with ls:

#ls -l usr
total 1
drwxr-xr-x  2 root  mj  512  9 Nov 10:00 local
#ls -l usr/
total 1
drwxr-xr-x  2 root  mj  512  9 Nov 10:00 local

ls does not differentiate usr and usr/ while cp does. To get what I'd like to
call 'ls -l usr' you have to do 

#ls -ld usr
drwxr-xr-x  3 root  mj  512  9 Nov 10:00 usr
(or ls -ld usr/ of course)

Why is this? I really like the subtle difference with the slash as in cp example
above.



While on the subject of strange behaviours, how about this to see all dot-files
in my ~.

#ls \.*

I explicitly tell it to show only strings starting with a '.', but does it (or
do I tell it to)? Oh, no. It lists every other file and directory as well. This
latter is probably due to my misunderstanding of regexps, but still...

Can anyone shed some light on this? I am very curious!

Cheers,
Micke
----------------------------------
Michael Josefsson, MSEE
mj@isy.liu.se

This message was sent by XFMail
running on FreeBSD 3.5-STABLE
----------------------------------


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.001109101101.mj>