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
foo bar bazand the program "cowsay", it would produce:
_____
< foo >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
_____
< bar >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
_____
< baz >
-----
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
(Maybe with additional text in between, doesn't really matter)
I know I can do this with a bash script:
#!/bin/sh
for w in $@; do
cowsay $w
done
But I can't imagine that there isn't another way to do it.
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:
locate foo | sed s/bar/baz/ | [other-processing] | [insert-magic-here] cowsay
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.