Piping in Bash (`echo "blah" | foo`)

In bash we can use the pipe character to pass some content to a command;
echo "blah" | foo


If I'm the author of the command foo, how can I access that content. eg "blah"?

As I understand it, "blah" should be the stdin for foo, however when I write the following implementation I get no result;
function foo() { # I like brackets, sue me
  echo "$@"
}

Though running foo "blah" works as expected. I'm guessing $@ is not the correct symbol to use for this
Was this page helpful?