=================================== DAT2330 Test Two A - Unix - Answers =================================== -IAN! idallen@ncf.ca Problem A - Marks: 3 On the Test Machine: Put the five-word sentence $1 isn't "easy money". into a new output file named easy_approx.txt in your HOME directory. Copy the sentence and all the punctuation exactly! Also append to this same output file a copy of the last line of the file /home/ian/dat2330/boat. The output file will contain exactly 212 characters. A - Chapter 2, Chapter 5, quotes.txt echo '$1 isn'"'"'t "easy money".' >easy_approx.txt -OR- echo \$1 \ isn\'t \"easy money\". >easy_approx.txt -OR- cat >easy_approx.txt $1 isn't "easy money". ^D -OR- ...use the vi text editor... tail -1 /home/ian/dat2330/boat >>easy_approx.txt Problem B - Marks: 3 On the Test Machine: Create a sub-directory named .copyme in your HOME directory that has exactly the same permissions as the existing directory /home/ian/dat2330/.copyme. B - Chapter 4 ls -ld /home/ian/dat2330/.copyme -OR- ls -la /home/ian/dat2330 mkdir .copyme chmod u=rx,g=x,o=r .copyme -OR- chmod 514 .copyme Problem C - Marks: 3 On the Test Machine: Put a translated copy of the file /home/ian/dat2330/untranslated.txt into the file named linux_translated.txt in your HOME directory. The translation should change the all the letters except z to their upper-case equivalents. C - Chapter 5 tr a-y A-Y linux_translated.txt Problem D - Marks: 3 On the Test Machine: From the file /home/ian/dat2330/boat extract the first 100 lines of the file into a file named top and the last 90 lines of the file into a file named bottom. Count the number of lines that contain the digit 1 (one) in the two new files. Which file contains the most matches? Place only those (most) matching lines into the file named linux_boat_most.txt in your HOME directory. D - Chapter 3, Floppix Labs head -100 /home/ian/dat2330/boat >top tail -90 /home/ian/dat2330/boat >bottom grep 1 top | wc -OR- grep -c 1 top grep 1 bottom | wc -OR- grep -c 1 bottom grep 1 bottom >linux_boat_most.txt Problem E - Marks: 3 On the Test Machine: Create a reverse-sorted list of all the names (just the names, also including any hidden names) contained in the directory /home/ian/dat2330/bigdir. Put the reverse-sorted output into the file named linux_bigdir_reverse_sorted.txt in your HOME directory. E - Chapter 3, Chapter 4 ls -a /home/ian/dat2330/bigdir | sort -r >linux_bigdir_reverse_sorted.txt -OR- ls -ar /home/ian/dat2330/bigdir >linux_bigdir_reverse_sorted.txt Problem F - Marks: 3 On the Test Machine: Show the full listing (permissions, owner, etc.) for all the non-hidden names (including files and directories) in the directory /home/ian/dat2330/bigdir that end in the letters n through z (inclusive). Put the output into the file named linux_bigdir_nz_list.txt in your HOME directory. F - Chapter 4, Chapter 5 ls -ld /home/ian/dat2330/bigdir/*[n-z] >linux_bigdir_nz_list.txt Problem G - Marks: 3 On the Test Machine: Create a directory named io under your HOME directory. Under the io directory, create two directories named phobos and mars. Under the phobos directory, create two files (any size) named jupiter and venus. Under the mars directory, create two files (any size) named metis and thebe; but, the name thebe should be a second name for the file named jupiter. G - Chapter 4 mkdir io io/phobos io/mars touch io/phobos/jupiter io/phobos/venus touch io/mars/metis ln io/phobos/jupiter io/mars/thebe Problem H - Marks: 3 On the Test Machine: there is a partially protected directory named /home/ian/dat2330/unix_test_two_DAT2330 containing five files with one-letter file names: a, b, c, d, and e. If any of the five file names are names for the same data, put only the full absolute pathnames that point to the same data into output file same_data.txt in your HOME directory. If all five names are names of different file data, put the word none into the output file. H - Chapter 4, Web page "File Nodes" ls -i /home/ian/dat2330/unix_test_two_DAT2330/a ls -i /home/ian/dat2330/unix_test_two_DAT2330/b ls -i /home/ian/dat2330/unix_test_two_DAT2330/c ls -i /home/ian/dat2330/unix_test_two_DAT2330/d ls -i /home/ian/dat2330/unix_test_two_DAT2330/e echo /home/ian/dat2330/unix_test_two_DAT2330/b \ /home/ian/dat2330/unix_test_two_DAT2330/c >same_data.txt Problem I - Marks: 3 From the Floppix file /etc/services select all lines that do not contain the character string udp and put those lines into the file floppix_service_no_udp.txt in your HOME directory on the Test Machine. I - Chapter 3, Floppix Labs grep -v udp /etc/services >floppix_service_no_udp.txt ftp 205.211.32.96 ftp> put floppix_service_no_udp.txt ftp> quit Problem J - Marks: 3 On the machine acadaix there is a readable compressed text file named /thome/alleni/dat2330/two/secone.gz containing a compressed text message. Extract a copy of the text from the file, read it, and do what the message says. J - Chapter 3 gzip -d tmp -OR- cp /thome/alleni/dat2330/two/secone.gz tmp.gz ; gzip -d tmp.gz more tmp mv tmp acadaix_onehide.txt ftp 205.211.32.96 ftp> put acadaix_onehide.txt ftp> quit