bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug


From: Bob Proulx
Subject: Re: bug
Date: Sat, 24 Feb 2001 13:08:52 -0700

I am in a jolly mood this morning and am having fun with this
message.  Please don't take it harshly.  I am worried it might sound
that way.

> There is a bug with the "ls -d" command with Redhat and possibly other
> vendors.

Thanks for your report.  But I believe you are mistaken.

> "ls -d" by definition should act the same as DOS's "dir
> /ad".

[Read this with a humorous tone.]  How do you deduce that ls -d should
be like dir /ad?  There is no connection between the two programs and
the defined behavior is not related.  I am not very familiar with that
new upstart operating system that uses 'dir /ad' either and so I can't
comment too closely about it.  Who would use a directory separator for
an option character anyway?  I really don't even know what those
options mean to dir.  Besides 'ls' predates MS 'dir' by years and so
if anything dir would be referring to ls and not the other way around.
UNIX is a very mature operating system and the behavior has been
stable while other operating systems have been changing their face and
their behavior every year or so.

On UNIX systems ls -d is defined, by definition, to be the following.

man dir:

       -d, --directory
              list directory entries instead of contents

info dir:

`-d'
`--directory'
     List just the names of directories, as with other types of files,
     rather than listing their contents.

The online UNIX standards documentation says:
  http://www.unix-systems.org/single_unix_specification_v2/xcu/ls.html

       -d   Do not treat directories differently from other types of
            files. The use of -d with -R produces unspecified results. 

Pretty much they all say the same thing.  Which should be
corroborating evidence of ls -d behavior.  Note that nothing anywhere
mentions 'dir' or 'dir /ad'!  :-)

> Instead of listing all of the directories in a given path, it
> only lists the current directory " . ", which serves no purpose. Am I
> the only one who has noticed this?

The -d option is meant to prevent ls from listing the contents of
directories when you only wnat it to list the names of the
directories.  While 'ls -d' by itself is sometimes useful the -d
option is most often used in conjunction with other options or in
conjunction with files listed on the ls command line.

Here is an example of the first case.  I frequently use 'ls -ld' to
view the ownership and permissions of the current directory.  Without
the -d option I would need to cd up a level to the parent directory
and then execute another ls -l on the upper level.  This is much more
succinctly done with 'ls -dl' in the current directory.  [Or when up
in the parent 'ls -dl dir'.]  Try running the 'ls -dl' command and
comparing that to the 'ls -l' and 'ls -la' commands.

Note that the default file/directory that ls lists is '.' if you don't
list one on the command line.  The man page lists this explicitly.
The info page appears to be missing that explicit statement.  You know
we use this command so much that the experts don't read the
documentation any more and so often little things like that are
missed.  Probably this should be added to the info page.  (I still
prefer man pages myself.)

In man ls:
       List information about the FILEs (the current directory by
       default).

But ls also acts upon files listed on the command line.  As another
way to understand the usefulness of the -d option try this example.
This uses -d in conjunction with files listed on the ls command line.
Compare the differences in the results of ls when you use the -d
option versus when you do not.

  ls -ld /etc/*.d
  ls -l /etc/*.d

For more information on UNIX operation I personally find the O'Reilly
nutshell handbooks to be excellent.

Hope this helps.

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]