"unwrap a sequence"

Hi
i have a list of random events from 1 to 20.000
imagine that , while collecting events, it arrives at 20.000 and then it wraps
from the beginning.
Is there a way to "unwrap"all sequences from the beginning?
For example to have a linear result in time.(not divided each time for "sets" of 1-20.000 evets .
Thanks in advance and congratulations for this forum

I'm guessing that's twenty thousand, not twenty point zero?

Double the length by appending the list to itself, start where you please for any number from 1 to 20000, count 20000 events and stop.

If each event is a line:

cat list list > /tmp/$$
# Skip 9 events and count 20000 more
tail -n +10 /tmp/$$ | head -n 20000

Without an example It's a little hard to understand what you input file is like.

I'm thinking of a file that has random increments to a standing count restarting at 20000 eg:

300
478
8221
9551
19100
678
12200
16721
18200

Required output is either:

Numerically sorted sort -n infile :

300
478
678
8221
9551
12200
16721
18200
19100

Or randomly shuffled shuf infile

19100
12200
9551
478
8221
18200
678
16721
300

Hi thanks for your answers .
No i mean : random values incrementing to 20.000 then it comes back and restart to 20.000.At the end ,imagine i have N groups of random values incrementing to 20.000. i would like to "unwrap" everything to be un-grupped and liner in time. (like a +1 at the end of each group)
thanks in advance
kind regards

Hmm. Please give an example with a model of your algorithm - a limit (sum I think :confused:) of a few "events" is just fine.

In other words we need to see actual numbers in an example.

Thanks

300 478 678 8221 9551 12200 16721 18200 19100
200 448 628 5221 9551 10200 15721 19200 19300

etc.. need continuity between groups like this . Events limit for each group can be from 0 to 20.000

the results are then plottable on a graph for example..

Not sure I understand, esp. as a sample output is still missing. With above data in file1 and file2, would this come close to what you want:

cat file[12] | tr ' ' '\n' | sort -n | tr '\n' ' '
200 300 448 478 628 678 5221 8221 9551 9551 10200 12200 15721 16721 18200 19100 19200 19300

thanks Rudi and all.
i think i have found a solution with python

thanks a lot for your Time.

Kind Regards

Please share your solution with the rest of us so that others who have might a similar problem will have a starting point for themselves.

Thanks, Bazza...

2 Likes