Consider:
command1 | command2
Is the output of command1 used as standard input of command2 or as command line arguments to command2?
<
Another form of redirection is process substitution.
grep "hehe" <(cat test.sh)
is equivalent to:
grep "hehe" test.sh
which both look at the contents of test.sh
itself.
While, as it has been noted, this command:
grep "hehe" $(cat test.sh)
looks for filenames in test.sh
and uses them as arguments for grep
. So if test.sh
consists of:
scriptone
scripttwo
then grep
is going to look for "hehe" in the contents of each of those files.