help-bash
[Top][All Lists]
Advanced

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

Re: case statement with non-consecutive numbers


From: Daniel Mills
Subject: Re: case statement with non-consecutive numbers
Date: Thu, 15 Apr 2021 13:36:30 -0400

On Thu, Apr 15, 2021 at 1:29 PM <pauline-galea@gmx.com> wrote:.

>
> Doing more work on this, it looks like using commas also works
>
>       case $k in
>         [1-2,4-5,7])  printf "%-21s" $s   ;;
>         [3,6,8])      printf "%-21s\n" $s ;;
>       esac
>
> Would that be correct?
>
>
>
>
 The commas aren't needed, now if "$k" is a comma it will also match the
pattern. Simply [368] or [1-24-57] is what you want there


reply via email to

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