case command and regex

Daniel Wayne Armstrong daniel-HRJVlgn2G/y5aS82P/H3Zg at public.gmane.org
Sun Mar 17 04:37:12 UTC 2013


On Sun, Mar 17, 2013 at 12:25 AM, William Park <opengeometry-FFYn/CNdgSA at public.gmane.org> wrote:
>> >> if [[ $1 =~ [\+\-]([0-9]+)+$ ]]; then
>> >>         echo "Match is $1"
>> >> else
>> >>         echo "No match."
>> >> fi
>
> Also, I think you can omit \, because it loses its meaning inside [].
> So,
>     if [[ $1 =~ ^[+-][0-9]+$ ]]; then
> should do equally well.

Indeed ... that works and looks more clean.

-- 
(o<  .: per curiositas ad astra .: http://www.circuidipity.com
(/)_
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list