linux - Bash: How to build a recursive cowsay -


here's linux command (you might need cowsay application.

cowsay 'moo' 

here's command:

cowsay 'moo' | cowsay -n 

the result pretty entertaining:

 ______________________________ /  _____                       \ | < moo >                      | |  -----                       | |         \   ^__^             | |          \  (oo)\_______     | |             (__)\       )\/\ | |                 ||----w |    | \                 ||     ||    /  ------------------------------         \   ^__^          \  (oo)\_______             (__)\       )\/\                 ||----w |                 ||     || 

now, of course, it's pretty fun repeat piped command n times. looks little 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 

cows nested inside cows saying things

but i'm thinking there must neater way of achieving this. let's want 500 cows saying each other, or 1,000, or 1,000,000. surely don't have keep finger on paste button?

here's question; there way in bash (command or script) recursively pass output of command given number of times?

cowsayn() {     local n=$1     shift     if ((n>1));         cowsay -n | cowsayn $((n-1))     else         cowsay -n     fi } echo 'moo' | cowsayn 500 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -