Workshop

The Workshop summarizes the key terms you learned and poses some questions about the topics presented in this chapter. It also provides you with a preview of what you will learn in the next hour.

Key Terms

file redirection Most UNIX programs expect to read their input from the user (standard input) and write their output to the screen (standard output). By use of file redirection, however, input can come from a previously created file, and output can be saved to a file instead of being displayed on the screen.

filter Filters are a particular type of UNIX program that expects to work either with file redirection or as part of a pipeline. These programs read input from standard input, write output to standard output, and often don't have any starting arguments.

standard error This is the same as standard output, but you can redirect standard error to a different location than standard output.

standard input UNIX programs always default to reading information from the user by reading the keyboard and watching what's typed. With file redirection, input can come from a file, and with pipelines, input can be the result of a previous UNIX command.

standard output When processing information, UNIX programs default to displaying the output on the screen itself, also known as standard output. With file redirection, output can easily be saved to a file; with pipelines, output can be sent to other programs.

Exercises

1:The placement of file-redirection characters is important to ensure that the command works correctly. Which of the following do you think will work, and why?
< file wc              wc file <           wc < file
cat file | wc          cat < file | wc     wc | cat

Now try them and see whether you're correct.

2:The wc command can be used for lots of different tasks. Try to imagine a few that would be interesting and helpful to learn (for example, to determine how many users are on the system right now). Try them on your system.
3:Does the file size listed by wc -c always agree with the file size listed by the ls command? With the size indicated by ls -s? If there is any difference, why?
4:What do you think would happen if you tried to sort a list of words by pretending they're all numbers? Try it with the command ls -1 | sort -n to see what happens. Experiment with the variations.

Preview of the Next Hour

The next hour introduces wildcards and regular expressions, and tools to use those powerful concepts. You learn how these commands can help you extract data from even the most unwieldy files.

You learn one of the secret UNIX commands for those really in the know: the secret-society, pattern-matching program grep. Better yet, you learn how it got its weird and confusing name!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.228.35