Skip to content

Instantly share code, notes, and snippets.

@glejeune
Created November 25, 2011 11:52
Show Gist options
  • Save glejeune/1393354 to your computer and use it in GitHub Desktop.
Save glejeune/1393354 to your computer and use it in GitHub Desktop.
Yet another FooBarQix solution
#!/bin/sh
_() {
[ $(expr $V % $1) == 0 ] && R=$(echo $R$2)
}
foobarqix() {
_ 3 "Foo";_ 5 "Bar";_ 7 "Qix"
R=$(echo $R$V | sed -e 's/3/Foo/g' | sed -e 's/5/Bar/g' | sed -e 's/7/Qix/g' | sed -e 's/[0-9]//g')
[ "Z$R" == "Z" ] && R=$V
}
for i in {1..100} ; do
export R=""; export V=$i
foobarqix
echo $i" : "$R
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment