LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] ls behaviour

[ILUG] ls behaviour

Gavin McCullagh gavin at fiachra.ucd.ie
Mon Jan 28 13:34:14 GMT 2002


Thanks to everyone for this.

gavin at fiachra gavin> shopt -u nullglob

was what I wanted.

Gavin

On Mon, 28 Jan 2002, John Tobin wrote:

> On Mon, Jan 28, 2002 at 11:36:21AM +0000, Gavin McCullagh wrote:
> ? 
> ? Hi all,
> ? 
> ? if I do 
> ? 
> ? ls lattice_*.dat
> ? 
> ? In the normal way I get back everything which matches that pattern.  Great.
> ? However, on the occasion that nothing matches it why do I get a full listing of
> ? the directory?  Why don't I get an empty list or file not found or
> ? something?
> 
> It depends on what arguments ls is given - without an argument you get
> the directory listing. If bash's "nullglob" option is set and no
> matches are found then "lattice_*.dat" is NOT given as an argument to
> ls. If it isn't set "lattice_*.dat" will be given to ls and you'll get
> the file not found error message. "shopt" will tell you whether it's
> set or not.
> 
> ? it's particularly irritating when you do something like
> ?
> ? for i in `ls lattice_*.dat`
> 
> for file in lattice_*.dat; do . . .
> will do what you want.
> 
> ? do
> ? rm $i
> ? done
> ? 
> ? and everything else gets deleted if there isn't a match of lattice_*.dat
> ? 
> ? It just doesn't seem very logical to me.
> ? 
> ? Gavin
> 
> -- 
> John
> "That would preempt a bunch of problems involved in trying to reconstruct
> exactly how the Perl 5 parser thinks, which nobody entirely understands."
> 			Larry Wall, 2001/04/20, perl6-language at perl.org
> "Finger to spiritual emptiness underlying everything." -- How a Japanese C
> manual referred to a "pointer to void".
> 
> -- 
> Irish Linux Users' Group: ilug at linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at linux.ie




More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell