I have a command-line program which takes input from stdin. What's the best way for me to pass a line of stdin into that program using bash? I have two approaches which accomplish the job, but they both seem a bit clunky.
I'll illustrate my approaches using a dumbed-down example of counting three words.
using a here doc:
wc -w <<EOS
one two three
EOS
using echo:
echo 'one two three' | wc -w
As I said, both of these seem a bit clunky. Is there a cleaner way to accomplish this?