Here's a linux command (you might need the cowsay
application.
cowsay 'moo'
Here's another command:
cowsay 'moo' | cowsay -n
The result is pretty entertaining:
______________________________
/ _____ \
| < moo > |
| ----- |
| \ ^__^ |
| \ (oo)\_______ |
| (__)\ )\/\ |
| ||----w | |
\ || || /
------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Now, of course, it's pretty fun to repeat that piped command N times. It looks a little like this:
cowsay 'moo' | cowsay -n | cowsay -n | cowsay -n | cowsay -n | cowsay -n | cowsay -n | cowsay -n | cowsay -n | cowsay -n | cowsay -n | cowsay -n
But I'm thinking there must be a neater way of achieving this. Let's just say I want 500 cows all saying each other, or 1,000, or 1,000,000. Surely I don't just have to keep my finger on the paste button?
Here's the question; is there a way in bash (command or script) to recursively pass the output of a command into itself a given number of times?
cowsayN() {
local n=$1
shift
if ((n>1)); then
cowsay -n | cowsayN $((n-1))
else
cowsay -n
fi
}
echo 'moo' | cowsayN 500
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With