Friday, October 3, 2008

Blog 6 -- Chapter 5a -- Utilities

Blog 6 -- Week 6

Assignment: Chapter 5 Self Test 1

1) If you are using 'more' to examine a file and decide you want to look back at the previous page, what do you enter?

A. 'b' or ctrl - B.

2) From 'more', how can you quickly start editing the current file with vi?

A. 'v' then <enter>. This starts the utility /usr/bin/vi.

3) What command tells 'cut' to output the first five characters of every line from the file 'practice'?

A. cut –c1-5 practice | more. The –c if for the character.

4) What command tells 'grep' to look for all lines consisting of only the letter 'Z' followed by any four characters in a file filename?

A. grep Z –a3 *.

5) What command instructs 'grep' to look through all files in the current directory for lines containing the string 'Pat Lloyd' and output just the names of the files that contain a match?

A. "grep –l 'Pat Lloyd' * | more". The '-l' tells grep to list the filenames not the individual lines.

6) How do you get the answer to the following with four figures to the right of the decimal point? Add 424 to 79, divide that sum by 161, then raise that result to the 15th power.

A. Start with 'bc', 424 + 79 (displays 503). 'scale=2' 503 / 161 (displays 3.12). 3.12 ^ 15th power (displays 25841570.87).

7) What command tells a utility to search through every file in the current directory for the name 'Catherine Thamzin'?

A. "grep 'Catherine Thamzin' *".

8) What command results in a listing of the number of words and the number of lines in the files 'practice' and 'users_on'?

A. wc –l -w practice users_on

9) What command creates a new file 'chapter' consisting of the contents of the files 'section1', 'section2', 'section3', and 'section4' with all the lines numbered?

A. cat 'section1', 'section2', 'section3', and 'section4' > chapter. Vi chapter (when in vi; type ':set number' and the numbers appear in front of each line.

10) A file called 'empnames' contains many employee names, with exactly one name on each line. What command outputs the names in the file in multiple columns, with columns filled before rows?

A. column 'empnames' | more. (just column fills columns first, column –x fills rows THEN columns). I am worried, I think the man says just the opposite. But I tried it and it worked this way.


No comments: