bug-fileutils
[Top][All Lists]
Advanced

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

Re: Error in LS.EXE


From: Bob Proulx
Subject: Re: Error in LS.EXE
Date: Mon, 19 Mar 2001 23:50:04 -0700

> There appears to be an error in the version of LS.EXE for use at a 
> Windows MS-DOS prompt.
> 
> Tested on 2 machines running Win98 SE, both on local and Netware 
> drives.
> 
> The -d or --directory option does not seem to work recursively.
> 
> Thus, on a machine with many subdirectories, LS -dR C:\
> (or -d -R or --directory -R)
> produces the output 
> C:\
> 
> only.

Thanks for the report.  But you are misunderstanding what the -d
option does.  It prevents listing directories.  It does not cause
recursion down the directory tree.  If you want to search the
directory tree and list all files in it you should be using the find
command.

The default directory to list if none is specified is the current
directory.  The -d option is meant to prevent ls from listing the
contents of directories when you only want it to list the names of the
directories.  So by default ls -d would list . which is not too
useful.  But when coupled with either wildcards on the command line or
other options such as -l it becomes a useful modifier.

For instance, if you were listing *.d and those were directories but
you did not know which existed 'ls -d *.d' would be most convenient to
list only the names.  Without the -d you would get the contents of the
directories and you would have no way of finding the names.

To understand the usefulness of the -d option try this example.  This
is on the UNIX operating system.  I realize you said you were using
windows but I have no comparable example there and since ls is
originally a unix command what more can I say.  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

The first lists the names and attributes of the directories in /etc
while the second lists the contents of those directories.  A much
different behavior.

If you want to list everything recursively you would need to supply
the -R option.  I personally don't find that very nicely formatted and
don't generally recommend it.  If you are looking to list all files
down a tree then using the find command works well.

  find . -print0 | xargs -0 ls -ld


The unix philosophy is that commands should do one thing and do it
well.  Complex behavior should be derived by combining smaller
programs.  Putting commands like this together is typical.  For
instance to list only directories in the current directory you might
use the following.

  ls -l | grep ^d

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

> Usage: C:\CD\TOOLS\UNIX\LS.EXE [OPTION]... [FILE]...
> Report bugs to address@hidden
> ls (GNU fileutils) 3.16
> -rwxrwxrwx   1 user        57856 Thu Nov 11 00:00:00 1999 ls.exe
> 
> By the way, it would be useful for DOS/Win versions not to report the
> number of users via a command-line switch. Of course, this may be 
> considered an undesirable modification to a platform-independent 
> tool.

Number of users?  I can't guess at what you are talking about.

> As somebody commented when I reported a very blatant error in the 
> MS-DOS version of another utility that hadn't been picked up, maybe 
> nobody is using these tools in DOS/Win?

I really can't say.  Note that I am not the maintainer but just
another hacker on the list.  The GNU utilities were originally
developed for use on UNIX systems such as HP-UX, SunOS, IBM AIX,
Linux, etc.  But they are designed to be as portable as possible.  And
since they use the GNU autoconf set of tools to compile the software
people found that they could be compiled under MS-DOS using a suitable
environment there such as Cygwin.  A lot of the functionality is not
supported by MS but for what is there works.  For the long time unix
user this brings a familiar UNIX command set to the MS environment.
But to the best of my knowledge none of the developers use MS
themselves so this is all second hand information.

The source is all open under the GNU copyright.  Anyone that wants can
compile it up for any environment.  And changes needed to better
support MS and other environments are gladly accepted by the
maintainers.  Someone apparently did compile this on MS for your
version of the code.  But I have no idea who that was and I don't
think anyone here has the ability to make a new version for you.
Certainly MS would not be considered the native environment for these
UNIX utilities.

Hope this helps.

Bob



reply via email to

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