Issue
I have two numbers that wrap over 255, let's say 254 and 2 I want to generate a sequence of "254 255 0 1 2"
So far I've tried following methods:
echo $(seq 254 2 || (seq 254 255 && seq 0 2))
echo $( (seq 254 2 || seq 253 255) && seq 0 2 )
echo $(seq 254 2 || seq 254 255 && seq 0 2)
Which return "", "0 1 2" and "0 1 2" respectively How can I achieve my desired result?
Solution
bash
myseq() {
local mod=$1 start=$2 stop=$3
while true; do
echo "$start"
(( start == stop )) && break
start=$(( (start + 1) % mod ))
done
}
Then
$ myseq 256 254 2
254
255
0
1
2
Answered By - glenn jackman Answer Checked By - Candace Johnson (WPSolving Volunteer)