Input redirection

You may want a file to be the input for a command that normally wouldn’t accept a file as an option. This redirecting of input is done using the “<” (less-than symbol) operator.

Below is an example of sending a file to somebody, using input redirection.

#mail buddies@serverbuddies.com < /tmp/mail.txt

If the user buddies exists on the system, you don’t need to type the full address. If you want to reach somebody on the Internet, enter the fully qualified address as an argument to mail.

This reads a bit more difficult than the beginner’s cat file | mail someone, but it is of course a much more elegant way of using the available tools.

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.