[Novalug] question about ls

Jon LaBadie novalugml@jgcomp.com
Mon Jan 16 14:31:41 EST 2012


On Mon, Jan 16, 2012 at 08:55:45AM -0500, Nino R. Pereira wrote:
> Thanks to all who replied.
> 
> I'm sorry to say that I mislead you. My command was not simply
> 
> ls -l
> 
> but it was
> 
> ls -l cryst*
> 
...
> 
> When I add a file, ls gives me exactly what I want, like so:
> 
> pereira@steve: touch crysta-
> pereira@steve:~$ ls cryst*
> crysta-
> 
> crystals:
> accounting orders quartz technical
> 
> except that it has that one pesky file that may or may not be there in 
> real life.
> Without this file I get:
> 
> pereira@steve:~$ rm crysta-
> pereira@steve:~$ ls cryst*
> accounting orders quartz technical
> pereira@steve:~$
> 
> where there's no indication of the directory's name that contains the 
> sub-directories
> (these are blue on my screen: "alias ls='ls --color=auto' ").
> 
> What option do I have to add to 'ls' to make the directory name appear?

Not an option, another dummy file name to make sure there are at least
two file arguments.

$ ls "" cryst*

Of course this will cause an error message about a file name ("")
of a non-existing file.  You can discard this (along with all other
errors as well).

$ ls "" cryst* 2> /dev/null

You could also put a function which does this in your shells rc file.
For example:

Ls () 
{ 
    /bin/ls ${@:+"$@" \"\"} 2> /dev/null
}

You could also add any options you normally use with ls,
such as turning on colors.

Jon
-- 
Jon H. LaBadie                  novalugml@jgcomp.com
 11226 South Shore Rd		(703) 787-0688 (H)
 Reston, VA  20190		(609) 477-8330 (C)



More information about the Novalug mailing list