|
|
Just as you can redirect the output of a command, you can redirect the input of a command. To tell a command to take input from a file, you type the command, then a less-than sign (<), then the file that you want it to use as input. The file used for input is still there after the command is finished; it is only read, it is not overwritten.
Suppose, for example, you wanted to mail a file called report to Doug you could type mail doug < report
This tells the mail command to take its input from report. This is a very fast way of mailing things because you never enter the interactive mail program, you just send the file.
Try mailing yourself a copy of /usr/adm/messages, the file that stores system startup messages, using input redirection:
Q: If I use redirection to mail a file to someone without entering the mail program, is there any way I can get a subject header on the message?
A:
You can get a subject header on the file by using
the -s "subject" option to
mail.
For example, to mail the file prognotes to Anne, you could type:
mail -s "Program notes" anne < prognotes
This sends the file with the subject heading ``Program notes.'' For more information about mail options, see mail(C).