[Top][All Lists]

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

[Help-bash] A 'for' loop through an empty directory

From: Christophe Lohr
Subject: [Help-bash] A 'for' loop through an empty directory
Date: Mon, 27 Oct 2014 10:18:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.1.2

Dear all,
I have a rather naive questionabout 'for' loop through a directory.
What happens if the directory is empty?

Let's try:
 $ for i in /foobar/* ; do echo $i; done

Why do I get the string '/foobar/*' and not nothing?
(note that there is no /foobar/ directory on my system)

In such a case, I would prefer having nothing rather than that.
Is there any option or trick to avoid this behavior ?

Best regards

reply via email to

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