#!/usr/bin/sed -f
# Script to do a weird thing asked for on IRC:
# output lines
# 3 5 7 9 13 35 57 79 135 357 579 1357 3579 13579
# a broken, weird sequence.
# We put the line number into the hold space.
1 {
s/.*/1/
h
d
}
x
# Teach sed to do arithmetics. painful.
s/$/A/
:loop
s/0A/10/
s/^A/10/
s/1A/20/
s/2A/30/
s/3A/40/
s/4A/50/
s/5A/60/
s/6A/70/
s/7A/80/
s/8A/90/
s/9A/A0/
tloop
# If there's something other than 0 at the end of the line, we're in trouble.
s/0$//
# Skip uninteresting lines
/^1\(3\(5\(79\{0,1\}\)\{0,1\}\)\{0,1\}\)\{0,1\}$/ ! {
x
d
}
#Default action: print.
x