[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: extglob pattern: @(/root) vs. @(root)
From: |
Clark J. Wang |
Subject: |
Re: extglob pattern: @(/root) vs. @(root) |
Date: |
Fri, 9 Dec 2011 21:25:54 +0800 |
On Fri, Dec 9, 2011 at 20:12, Stephane CHAZELAS
<address@hidden>wrote:
> 2011-12-9, 16:16(+08), Clark J. Wang:
> > See following:
> >
> > # shopt extglob
> > extglob on
> > # echo $BASH_VERSION
> > 4.2.20(1)-release
> > # ls -d /root
> > /root
> > # pwd
> > /
> > # echo @(root)
> > root
> > # echo @(/root)
> > @(/root) <-- ???
> > # echo @(/root*)
> > @(/root*) <-- ???
> > #
> >
> > I'm confused why @(/root) and @(/root*) do not work here.
>
> Globbing operators (*, ?, [/], @(..)) don't match "/". "/" has
> to be inserted literally.
>
> See the doc:
>
> When a pattern is used for filename expansion, the character `.' at
> the start of a filename or immediately following a slash must be
> matched explicitly, unless the shell option `dotglob' is set. When
> ~~~~
> matching a file name, the slash character must always be matched
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> explicitly. In other cases, the `.' character is not treated specially.
> ~~~~~~~~~~
>
Thanks. I see the point now. I never really noticed that before since
things like `echo /root*' always worked fine. :)
>
> --
> Stephane
> >
>
>
>
--
-Clark