Using File Redirection Metacharacters

Commands receive data from standard input and send it to standard output. Using pipes (described earlier), you can direct standard output from one command to the standard input of another. With files, you can use less than (<) and greater than (>) signs to direct data to and from files. Here are the file-redirection characters:

■ < — Directs the contents of a file to the command. In most cases, this is the default action expected by the command and the use of the character is optional; using more bigfile is the same as more < bigfile.

■ > — Directs the standard output of a command to a file, deleting the existing file.

■ 2> — Directs standard error (error messages) to the file.

■ &> — Directs both standard output and standard error to the file.

■ >> — Directs the output of a command to a file, adding the output to the end of the existing file.

Here are some examples of command lines where information is directed to and from files:

Digital Cameras For Beginners

Digital Cameras For Beginners

Although we usually tend to think of the digital camera as the best thing since sliced bread, there are both pros and cons with its use. Nothing is available on the market that does not have both a good and a bad side, but the key is to weigh the good against the bad in order to come up with the best of both worlds.

Get My Free Ebook

Post a comment