help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Matching file pattern excluding some exceptions


From: DJ Mills
Subject: Re: [Help-bash] Matching file pattern excluding some exceptions
Date: Mon, 6 Aug 2012 11:04:48 -0400

On Sun, Aug 5, 2012 at 9:41 PM, Clark WANG <address@hidden> wrote:
> On Mon, Aug 6, 2012 at 5:52 AM, Peng Yu <address@hidden> wrote:
>>
>> Hi,
>>
>> Suppose that I want match all *.cpp except main*.cpp files. Instead of
>> using other utilities like find or grep, is there a way to use native
>> bash features by extend the following code to do so?
>
>
> shopt -s extglob
> echo !(main*).cpp
>>
>>
>> shopt -s nullglob
>> set -- *.cpp
>>
>> --
>> Regards,
>> Peng
>>
>

See http://mywiki.wooledge.org/glob

Make sure that extglob is set _before_ the line that needs it is
parsed. It alters the
way bash parses, and therefore cannot be set on the same line, or in the same
compound command. The best practice is to set it right under the shebang.



reply via email to

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