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 output can be redirected to other places. For example ls, which would normally display the directory list to the screen, can easily have that output redirected to a file like this:

$ ls > filelist.txt

This will create a text file called filelist.txt that contains the directory list of the current directory. This is known as output redirection.

If the directory list is too long to fit on the screen, I can pipe its output to the more program like this:

$ ls | more

You may recall that the more command displays text sent into it one screen at a time. This will prevent the directory ...

Get FreeBSD® 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.