Re: Bash globbing files only?

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

 



On 31Jan2007 08:47, Daniel Qarras <dqarras@xxxxxxxxx> wrote:
| > A POSIX shell requires that the test command supports this:
| > 
| >        -h  file
| >               True if file exists and is a symbolic link.
| >        -L  file
| >               True if file exists and is a symbolic link.
| 
| Thanks, I already saw those but initially they did not work for
| directories. That was because I had
| 
| dirs=[^.]*/
| 
| that would expand, e.g:
| 
| foo/
| bar/
| 
| and the trailing slash caused -L test to fail.

Indeed, because it forces a test to be _not_ on the symlink but on what
is on the far side of it.

BTW, if you've been following this thread you should know that:

  [^.]*/

is better written:

  */

which means _exactly_ the same thing.

Of course, you realise that you may not need to test for -d at all
because */ will only return directories (or things pointing at them).
(Except when there are no directories at all - the it returns "*/"
unchanged and you just need to test for existence.)

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

Haven't been there. Don't want to go. Don't need another t-shirt!
        - Lisa Varner <varner@xxxxxxxxxxxxxxxxxxxxxx>


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux