Pipes and Input/Output Redirection

One of the things that makes UNIX so powerful is the fact that output from one command can be used as the input to another command, and the final output can be redirected to other places than just the screen. You can get a listing of files or the output of a program, pipe it into grep to filter out irrelevant lines, and then send it through fmt to process it for easy reading—all on the same command line. These kinds of tasks are very frequently useful in system administration tasks such as log file processing and filesystem auditing. For example, ls would normally display the directory list to the screen, but it can easily have that output redirected to a file, like this:

# ls > filelist.txt

This will create ...

Get FreeBSD6 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.