Assignment 1 (10 marks) Part a) (5 marks) The provided “Problem1” directory contains a file named “answer.txt”, which is a text file that holds the answer. Try to show the contents of a file with cat. For example:
(Hint, you are NOT supposed to see the contents of this file yet!) Write a description of the outcome of this command in your solution text file, q1.txt. Your answer can be just a few words, but make sure to include the other commands that you ran in order to diagnose any failures along with their output. Part b) (5 marks) Fix the problem with the “answer.txt” file so that you are now successfully able to use the “cat” command above to view the file contents. Copy the sequence of commands that you used and their outputs into your solution text file, q1.txt. Make sure to copy the contents of the file into your written answer, to prove it worked. 2. Your Personal Zoo (40 marks) One of the most common and lucrative uses of computers today is spending hours looking at cute animal photos. We have provided 8 of these in the archive file, and you must write a BASH script, q2.bash, that displays N of them at a time (N is a commandline argument), using Linux’s eog image viewer, cycling endlessly until your script is killed. Usage: $ bash q2.bash N Quickly opens N images for viewing. No more and no less. ● The order of images shown must be “fair”: that is you must show each image once before repeating any, each twice before repeating any three times, etc. ● When the user closes an image viewer, a new image must be shown in less than 2 seconds, ensuring optimal timewast… entertainment is achieved, and keeping exactly N viewers open at all times. ● Your script must only end when interrupted with Ctrlc ● Hint: Ensure to use the “eog n” option, which makes sure each image you open uses an independent (new) process. ● Hint: ps is a helpful command to determine how many viewers are open currently. ● Helpful tip: After sending ctrlc to your script, your eog processes will likely stay open. To prepare for a new run of your script, run “$ killall eog”. Sample session:
3.Sort the Animals (50 marks) Along with each animal image from Question 2, we have also provided a “.dat” files with a few properties of each, like their weight and height. You must create a BASH script, q3.bash that sorts the animals based on a property given on the command line: ● $ bash q3.bash alpha sorts by increasing alphabetical order of animal name ● $ bash q3.bash weight sorts by increasing weight ● $ bash q3.bash length sorts by increasing length You must output your result in 2 ways. First, the ordered list must be printed as standard output (shown on the terminal), one name per line. Second, you must combine all of the animal images into one file called “result.jpg”, with the ordering of animals shown respecting the requested sort order. Look at the “convert append” command for producing the joinedimage output. The table below shows desired results when run with each arguments: Alpha Weight Length blue_whale crocodile elephant giraffe hippopotamus humpback_whale ostrich sea_turtle