Friday, February 27, 2009

CIT 174

Week 5
Chapter 5 Review Questions
1. A regular expression is used to (c) define a potentially complex pattern of characters or digits.
2. The regular expression [cC]hapter0[12345]* does not match which of the following files? (c) Chapter1.doc .
3. Which of the following regular expressions matches the text "Reunion-2004"? (c) [Rr]eunion[0-9]{4}.
4. The grep command is not useful for which of the following? (b) determining which directories are currently in use.
5. Searching documents created by word-processing programs is not an appropriate use of the grep command because (d) word-processing documents contain non-readable codes (non-text information).
6. If you execute a grep command without providing the name of one or more files to search, you should (a) provide input using a pipe from another utility.
7. You need to track the output of a text file in real time as lines are added to that file by another program. Which command would you use? (b) tail -f.
8. Several commands are available in Linux that let you compare two or more files to determine how they differ. One of these programs in particular is widely used by programmers and system administrations and is a tool commonly used for assisting with modified source code on Linux systems. It is called (a) diff. (“cmp”-are files identical and “comm.”-are sorted files the same)
9. Which of the following features is not supported by default in ispell? (/) ispell supports all theses options and I don’t see one of these answers in the book.
10. The wc command displays (a) the number of lines, words, and characters in a file.
11. Name five programs that can be used to filter text files in Linux. (command line programs)
a. sort
b. uniq
c. sed
d. awk
e. vi, pico, or emacs.
12. The command ls | sort causes which of the following to occur (a) the output of the ls command is sent to the sort command and the results are printed to the screen.
13. When you run a program called gather_data, it normally reads text as a user enters it at the keyboard. If you use the command gather_data < input_text to run the program, which of the following occurs? (b) the input that the gather_data program normally reads form the keyboard is taken form the input_text file instead.
14. Which independent Linux command replaces tabs in a text file with a fixed number of spaces? (c) expand.
15. The name of a script file can be provided to sed or awk on the command line using which command-line option? (a) file
16. Using a ! (bang) along with a standard write command in vi causes the editor to (a) attempt to write the file despite a file permission that does not by itself permit writing the file, thought this can only be done if the person editing the file is the owner of that file OR is working as root.
17. Which of the following creates a mark at the current line within vi so that you can quickly jump to that line in the file? (b) ‘a.
18. The vi editor checks for an environment variable and for a hidden initialization file in the directory in which a file being edited is stored. These are called, respectively (b) EXINIT, .exrc.
19.Describe the meaning of 1, $ as a range operator at the beginning of a search and replace command within vi. The range 1, $ means from the first line to the last line of the file.
20. Describe the difference between the following four search commands in vi:
/ --looks for a pattern from the current position FORWARD.
? – looks for a pattern from the current position BACKWARD.
N – jumps to the NEXT occurrence of the most recent search pattern ( / or ? )
N jumps to the PREVIOUS occurrence of the most recent search pattern ( / or ? )

No comments: