[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: case statement with non-consecutive numbers
From: |
Greg Wooledge |
Subject: |
Re: case statement with non-consecutive numbers |
Date: |
Thu, 15 Apr 2021 13:59:54 -0400 |
On Thu, Apr 15, 2021 at 01:36:30PM -0400, Daniel Mills wrote:
> 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
And for the record, [1-2] and [12] are the same, so you can remove the
hyphens as well. You need a range of at least 3 characters in a row
for the hyphen to break even, and 4 for it to actually shorten the glob.
- case statement with non-consecutive numbers, pauline-galea, 2021/04/15
- Re: case statement with non-consecutive numbers, Greg Wooledge, 2021/04/15
- Re: case statement with non-consecutive numbers, pauline-galea, 2021/04/15
- Re: case statement with non-consecutive numbers, Daniel Mills, 2021/04/15
- Re: case statement with non-consecutive numbers,
Greg Wooledge <=
- Re: case statement with non-consecutive numbers, pauline-galea, 2021/04/15
- Re: case statement with non-consecutive numbers, Greg Wooledge, 2021/04/15
- Re: case statement with non-consecutive numbers, Greg Wooledge, 2021/04/15
- Re: case statement with non-consecutive numbers, Dennis Williamson, 2021/04/15
- Re: case statement with non-consecutive numbers, Greg Wooledge, 2021/04/15
- Re: case statement with non-consecutive numbers, Dennis Williamson, 2021/04/15
- Re: case statement with non-consecutive numbers, pauline-galea, 2021/04/15
- Re: case statement with non-consecutive numbers, Dennis Williamson, 2021/04/15
- Re: case statement with non-consecutive numbers, pauline-galea, 2021/04/15
- Re: case statement with non-consecutive numbers, Dennis Williamson, 2021/04/15