Assignment #3 Name: Full E-mail Address: UNIX System Used: 1. What will be the result when the following commandline is run: $ (date; cal) & (sleep 15; whoami & uname -a) (a) Which of these commands run sequentially and which run in parallel? (b) How many of the processes run in parallel? Hint: Use the ps f command in a second window to verify. 2. Write a commandline that compares the number of words in two files: /usr/teacher/tab and /usr/teacher/tac in order to determine which file is larger. State which file has the least number of words? 3. Explain what happens when you give the following commands. $ student=Joe $ echo $'student' $ student=Evan $ echo $\student $ student=Lee $ echo $"student" $ student=Rob $ echo "$student" $ student=Bon $ echo '$student' $ student=Mindy $ echo $$student $ student=Sam $ echo $\$student $ student=Jeannie $ echo \$$student $ student=Susan $ echo $student\ What does this imply about the order in which the shell processes commands? 4. Explain what each of the following commands does. Assume that they are run in the order shown. $ umask a=r,u-wx $ echo Keep aware and expand everything > f1.out $ echo Be safe >> f1.out $ set -o | tee t.out | grep verbose $ cat t.out | grep xtrace $ grep xtrace < t.out $ echo ~newkatz | grep newkatz | cat >> f1.out $ echo ?.out ??.out $ grep expand *.out | wc -l $ grep expand < f*out | wc -l 5. Suppose you have a file called passwordfile, containing: $ cat passwordfile Z6E3er6Y Te93es8U 3z4WKAJ8 9s4RPJU6 Dy85jm4E 83jAxK6a 4x8TZEU8 Ca66jg4U F2A7jk2E 7p4PZAU4 Zu28yw8A 9k7KSAA8 D2U6js2A Hj83jk6J 2s4BNEA5 77yJvW4y Zy75us6Y 3m3PXUA8 5Jz27AM5 Te95ah5A H3U8yj7Y 8b6TTUU3 Fu42ut5J 2n2HWJJ2 R3A5jx5J Xa36ux8Y 7AYK85w2 2w4XKYA2 Za65ab8Y 2Ar72JV6 77aUjX7j Ta43yk3Y N8E6yg5Y 4AUJ76b5 Ka37yw3U 95yUzG6j B9A8ar7J Wj96ax2J 2f4BBJY8 2v6BBEJ2 J5a7vdq3 i6b8weR4 (a) Write a commandline using grep on this file that matches lines containing the sequenced numbers: 69, 38, 48 in any order, when the letters are ignored. (b) Write a commandline using grep on this file that matches lines containing the sequenced letters: jk, js, jj in that order, when the digits are ignored. 6. Go to the URL: www.cnn.com/WEATHER and record the high and low Temperatures for the following major cities in Asia: Kuala Lampur Karachi Tokyo Lahore Manila New Delhi Jakarta In a file called weather.txt, construct an ascii table comprising one line per city in the format: City Name{tab}High Temperature / Low Temperature The following is a sample line: Tokyo 88 / 82 Give the commands to do the following: (a) Sort the table by City Name (b) Sort the table by High Temperature (c) Sort the table by using the city name as the primary key and the low temperature as the secondary key (d) Produce a new file that has the format: High Temperature F City Name{tab}Low Temperature F for example: 88 F Tokyo 82 F 7. (a) Which file(s) contain your primary prompt variable ? (b) Backup the file or files above that you own. (c) Modify your prompt to contain on the first line what it currently contains and on the second line also contain the time of day (Hours, Minutes only) followed by a bracket enclosed updatable command number and then a %. For example: rkatz@ned rkatz 19:15 [34] % (d) Write about your experiences (good and bad) in answering this question. 8. (a) Write a regular expression(s) that matches the characters on Florida passenger Car License Plates since 1985. See: www.plateshack.com/florida/florida.html (b) Write a regular expression that matches exactly two identical repeated vowels. (i.e.: uu in vacuum match; u's in usual don't match) (c) Write a regular expression that characterizes the first 4 colon delimited fields of the /etc/passwd file. 9. Write a function that displays all its arguments except the first three on STDERR and exits. Type in the program and test it out. 10. Write a shell script (program) named diet that displays a file without the first and last n lines, where n is an integer and the command is specified for example as: $ diet -5 file Type in the program and test it out. 10 Points Extra Credit: Modify the diet script so that it permits two different values, one for the number of lines to suppress starting from the top of the file and the other for the number of lines to suppress starting from the bottom of the file. Be sure to handle the case when the number of lines suppressed exceeds the number of lines in the file. For example: $ diet -3 -8 file will eliminate the first three lines and the last 8 lines and output all the other lines in between.Questions about the questions? Send mail to Robert Katz: rkatz@ned.highline.edu