[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: extglob pattern: @(/root) vs. @(root)
From: |
Stephane CHAZELAS |
Subject: |
Re: extglob pattern: @(/root) vs. @(root) |
Date: |
Fri, 9 Dec 2011 12:12:40 +0000 (UTC) |
User-agent: |
slrn/pre1.0.0-18 (Linux) |
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.
~~~~~~~~~~
--
Stephane
>