$ perl -e '$i=1; while (1) { print $i, "\n"; $i = $i % 5 + 1 }' | head -10 1 2 3 4 5 1 2 3 4 5