Skip to content

Instantly share code, notes, and snippets.

/sample_program.sh
Created Sep 26, 2014

Embed
What would you like to do?
#!/bin/bash
function generator() {
local I=1
while [ $I -le 50 ]; do
echo "Line $I"
let I+=1
done
}
function alternator() {
local LN=0
while read -r LINE; do
test $((LN % 2)) -eq 0 && echo "$LINE" || echo "$LINE" 1>&2
let LN+=1
done
}
generator | alternator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.