case command and regex

William Park opengeometry-FFYn/CNdgSA at public.gmane.org
Sun Mar 17 04:25:12 UTC 2013


On Sat, Mar 16, 2013 at 11:54:59PM -0400, Daniel Wayne Armstrong wrote:
> On Sat, Mar 16, 2013 at 10:53 PM, William Park <opengeometry-FFYn/CNdgSA at public.gmane.org> wrote:
> > On Sat, Mar 16, 2013 at 08:15:49PM -0400, Daniel Wayne Armstrong 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.
-- 
William
--
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