M
M
Myr4ik2019-05-14 10:09:52
Command line
Myr4ik, 2019-05-14 10:09:52

How to combine consecutive numbers into ranges?

Hello!
Tell me, please, with what and how can you combine the sequence of numbers
1
2
3
4
5
9
12
13
14
into the ranges
1-5,9,12-14?
It is preferable to do this in the FreeBSD CLI.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hint000, 2019-05-14
@Myr4ik

for you and for my own warm-up, I wrote this one-liner:
if you feed him your numbers (like you have, one number per line), then it outputs:

1-5, 9, 12-14

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question