Similar to using >
on the bash command line, you can also use
<
to redirect a file into a command. For many commands,
you can simply specify the filename on the command line, however some commands
work only from standard input.
Bash and other shells support the concept of a "herefile". This allows you to
specify the input to a command in the lines following the command invocation,
terminating it with a sentinel value. Here's an
example:
$ sort <<END
apple
cranberry
banana
END
apple
banana
cranberry
In our example, we typed the words apple
,
cranberry
, and banana
, followed by "END" to signify
the end of the input. The sort
program then returned our words in
alphabetical order.