title: Executing for-each in bash
body: <p>I'm looking to write a Bash one-liner that calls a function once for each item in a list. For example, given the list <pre>foo bar baz</pre> and the program "cowsay", it would produce:</p>
  
  <pre><code> _____
  &lt; foo &gt;
   -----
          \   ^__^
           \  (oo)\_______
              (__)\       )\/\
                  ||----w |
                  ||     ||
   _____
  &lt; bar &gt;
   -----
          \   ^__^
           \  (oo)\_______
              (__)\       )\/\
                  ||----w |
                  ||     ||
   _____
  &lt; baz &gt;
   -----
          \   ^__^
           \  (oo)\_______
              (__)\       )\/\
                  ||----w |
                  ||     ||
  </code></pre>
  
  <p>(Maybe with additional text in between, doesn't really matter)</p>
  
  <p>I know I can do this with a bash script:</p>
  
  <pre><code>#!/bin/sh
  
  for w in $@; do
    cowsay $w
  done
  </code></pre>
  
  <p>But I can't imagine that there isn't another way to do it.</p>
  
  <p>EDIT: I wasn't very clear in my initial question, I think. I want to be able to do something like this without writing a bash script:</p>
  
  <pre><code>locate foo | sed s/bar/baz/ | [other-processing] | [insert-magic-here] cowsay
  </code></pre>
  
  <p>The point is that I'm trying to avoid having to write a script, so that I can just add it to my pipe chain and not think about it.</p>