Assignment 6.doc

advertisement
CST 334
ASSIGNMENT 6
Chapters 3,5,6 (selected)
DUE: Next Wed
Wildcards: Forouzan 3.1; Redirection&Pipes: 5.2,5.3,5.4; Job Control: 5.10 Filters: Ch6
1. In the /home/cst334 directory is a file called mars.txt (we've been working with already)
From your home directory, copy the file to your home directory__________________
2. Translate (tr) the mars file into CAPS using the mapping: [a-z] [A-Z] and pipe it into
more_______________________
What happens? ___________________
3. Another translation converts capital letters into “biff-speak”, a computer-ese looking readout
The appropriate translation is AEIOS to 43105 (A’s become 4’s, E’s become 3’s etc)
Chain two translations together (lowercase to upper case, then upper case to “biff-speak” ) using pipes
and also pipe the final output into more______________________________________
is this cool?____________
3. Type
man ls and experiment with the various options. Which option shows size? ____________
5. What happens when you type ls -lAF _________________________________ ( Interpret each option)
Is the following (rearranged options) any different? ls -FlA_________
6. Use cat to display 3 files on the screen at once (bio, foods, mars.txt): ____________________
7. Now use redirection to put the same three files into a single file named file_all _________________
8. Add your foods file to the file_all file again using the append >> redirection __________________
9. Which of the following commands can (or cannot) be used with input redirection? Explain the rationale for
your answer.
a) cal
d) cp
b) date
e) who
c) echo
f) passwd
10. Which of the following commands can (or cannot) be used with output redirection? Explain the rationale
for your answer.
a) cal
d) cp
b) date
e) who
c) echo
f) passwd
11. Assuming file1 is a text file, what is the error (if any) in each of the following commands?
a)
date | more
d) more | sort
b)
more | date
e) who | man
c)
date | file1
f) file1 | date
12. If we use the following chained command:
command1 | command2
a) What is the necessary requirement for command1?
b) what is the necessary requirement for command2 ?
13. You have the following files in your home directory:
file1
file2
file33
file4
NFile1
Nfile2
Nfile441
file1a
f5
file2a
f6
file2b
f7
Which of them would be selected by each of the following patterns?
a) file?
b) file??
c) file*
d) Nfile?
e) ?file?
11. Write a wildcard pattern ( use *, ?, or []) to refer to all the files in the lines below:
a) file1, file2, file3…file9
Example:
file?
b) file0 … file99
________________
c) file20, file21, file22…file29
(but not file11 or file33 etc)
________________
d) All files ending with
.c
________________
e) all files in the parent directory
________________
f) All files starting with a letter
________________
12. Open another window and log in, then start vi on a junk file (vi junk)
13. In your first window, find out what the process ID number is for the vi (actually, it's mapped to vim)
process________________
14. Kill the vi process from your first window ________________
Practice with Unix Filters
15. Use vi to create a file containing the following data. Call it Lab6s1
Use a single tab to separate each field.
1425
YourName
19.24
4321
George
67.15
8634
Louise
18.76
1426
Caspar
73.10
2315
Helen
74.43
16. Use the cat command display the file and check for accuracy.
17. Use vi to correct any errors in the file.
18. Use the sort command to sort the file according to the first field
And save the sorted output as Lab5s1b using redirection
________________
Use a command to show the number of workers
________________
19. Extra Credit: (2 points)
a. Use a command to sort the file by name ________________
b. Use a single piped multi-command to show the worker who is paid the highest rate (should
work on any file with similar format) ________________
Download