=================================== DAT2330 Test Two B - Unix - Answers =================================== -IAN! idallen@ncf.ca Problem A - Marks: 3 On the Test Machine: Put the five-word sentence $0 isn't "any money". into a new output file named zero_money.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/train. The output file will contain exactly 209 characters. A - Chapter 2, Chapter 5, quotes.txt echo '$0 isn'"'"'t "any money".' >zero_money.txt -OR- echo \$0 \ isn\'t \"any money\".' >zero_money.txt -OR- cat >zero_money.txt $0 isn't "any money". ^D -OR- ...use the vi text editor... tail -1 /home/ian/dat2330/train >>zero_money.txt Problem B - Marks: 3 On the Test Machine: Create a sub-direc­ tory named .mycopy in your HOME directory that has exactly the same permissions as the existing directory /home/ian/dat2330/.mycopy. B - Chapter 4 ls -ld /home/ian/dat2330/.mycopy -OR- ls -la /home/ian/dat2330 mkdir .mycopy chmod u=r,g=rx,o=x .mycopy -OR- chmod 451 .mycopy Problem C - Marks: 3 On the Test Machine: Put a translated copy of the file /home/ian/dat2330/nottranslated.txt into the file named linux_translatedone.txt in your HOME directory. The translation should change the all the letters except a to their upper-case equivalents. C - Chapter 5 tr b-z B-Z linux_translatedone.txt Problem D - Marks: 3 On the Test Machine: From the file /home/ian/dat2330/train extract the first 80 lines of the file into a file named first and the last 110 lines of the file into a file named last. Count the number of lines that contain the digit 0 (zero) in the two new files. Which file contains the most matches? Place only those (most) matching lines into the file named linux_train_most.txt in your HOME directory. D - Chapter 3, Floppix Labs head -80 /home/ian/dat2330/train >first tail -110 /home/ian/dat2330/train >last grep 0 first | wc -OR- grep -c 0 first grep 0 last | wc -OR- grep -c 0 last grep 0 first >linux_train_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/largedir. Put the reverse-sorted output into the file named linux_largedir_reverse_sorted.txt in your HOME directory. E - Chapter 3, Chapter 4 ls -a /home/ian/dat2330/largedir | sort -r >linux_largedir_reverse_sorted.txt -OR- ls -ar /home/ian/dat2330/largedir >linux_largedir_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/largedir that end in the letters a through m (inclusive). Put the output into the file named linux_largedir_am_list.txt in your HOME directory. F - Chapter 4, Chapter 5 ls -l /home/ian/dat2330/largedir/*[a-m] >linux_largedir_am_list.txt Problem G - Marks: 3 On the Test Machine: Create a directory named thebe under your HOME directory. Under the thebe directory, create two directories named jupiter and venus. Under the jupiter directory, create two files (any size) named phobos and mars. Under the venus directory, create two files (any size) named metis and io; but, the name io should be a second name for the file named phobos. G - Chapter 4 mkdir thebe thebe/jupiter thebe/venus touch thebe/jupiter/phobos thebe/jupiter/mars touch thebe/venus/metis ln thebe/jupiter/phobos thebe/venus/io 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-digit file names: 1, 2, 3, 4, and 5. 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_digit.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/1 ls -i /home/ian/dat2330/unix_test_two_DAT2330/2 ls -i /home/ian/dat2330/unix_test_two_DAT2330/3 ls -i /home/ian/dat2330/unix_test_two_DAT2330/4 ls -i /home/ian/dat2330/unix_test_two_DAT2330/5 echo /home/ian/dat2330/unix_test_two_DAT2330/4 \ /home/ian/dat2330/unix_test_two_DAT2330/5 >same_digit.txt Problem I - Marks: 3 From the Floppix file /etc/services select all lines that do not contain the character string tcp and put those lines into the file floppix_service_no_tcp.txt in your HOME directory on the Test Machine. I - Chapter 3, Floppix Labs grep -v tcp /etc/services >floppix_service_no_tcp.txt ftp 205.211.32.96 ftp> put floppix_service_no_tcp.txt ftp> quit Problem J - Marks: 3 On the machine acadaix there is a readable compressed text file named /thome/alleni/dat2330/two/twosec.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/twosec.gz tmp.gz ; gzip -d tmp.gz more tmp mv tmp acadaix_twohide.txt ftp 205.211.32.96 ftp> put acadaix_twohide.txt ftp> quit