[SOLVED] html graph 1. Reconstructingls

$25

File Name: html_graph_1._Reconstructingls.zip
File Size: 282.6 KB

5/5 - (1 vote)

1. Reconstructingls
You are working at a company which, sadly, only has access to a very old version of thelscommand. Recent versions provide the ability to sort files by their size (in bytes), using the-Sswitch, but the version your team uses does not have this. You also may not use thesort=sizeoption, which has exactly the same effect.
Withoutusing the new-Sswitch, develop a script calledls_by_size.shto list files, sorted by their size.
[10 marks]
2. Words
Given a file ofsimple text, as a sample, develop a script calledword_counter.shto uniquely list all words found in a file (list each unique word once). Well define a word to be any sequence of one-or-more alphabetic characters, the words Hello and hello are distinct words, and all other non-alphabetic characters should be ignored. Your script should read from standard input, and write to standard output.
[10 marks]
3. Weather
Your colleagues have been complaining that on the weekend, the weather is worse than during the working week (when they are unable to enjoy it as much).
Look at the Bureau of Meteorology page containing Perth daily weather observations:http://www.bom.gov.au/climate/dwo/IDCJDW6111.latest.shtml. The page contains a link to a plain text version of the page data, in.csv(comma-separated value) format.
Write a script which downloads the.csvfile from the BOM site, and analyses the results of the current month to determine how enjoyable each days weather is. (You may use your own definition of enjoyable, but it should involve at least 3 columns from the data, and you should add a comment in your script justifying the definition.) Call your scriptweekends.sh. It should output one line per day, containing two columns, separated by commas: the date (inYYYY-MM-DDformat note that this is different to the format used in the BOM data file), and a column saying either enjoyable or unenjoyable.[5 marks]
Then write a script calledweather_analyser.sh, which can be used to analyse the output ofweekends.shand report whether the weather on weekends is, indeed, less enjoyable than that of weekdays. You may use whatever analysis you like, but should add comments in your script justifying it. Your script should simply output the word supported or unsupported depending on weather the data it is given supports, or does not support, the claim that weekend weather is worse.[5 marks]
4. Plague
It is London, 1854, and plague stalks the land. You have accepted a data science position with physicianJohn Snow, who is investigating possible causes of a cholera outbreak in London. His data is available in tab-separated format athttp://www.randomservices.org/random/data/Snow.html(see the links at the bottom of the page).
He has two files, containing data on the locations of water pumps in London, and the location of people who have died of cholera.
He asks you to develop two different visualizations of the data to display to London public officials. Write two scripts,vis1.shandvis2.sh, which will analyse the data and create a visualization, producing HTML output. The scripts should take two command-line arguments, for adeathsfile and apumpsfile, and send their output to standard output.
You may choose the representations. However, only one representation may be a simple one,such asa histogram. The other should present some more insightful information (trends, geographical imagery, etc.).
[5 marks per script]

Frequently Asked Questions
Question 1
Can we use thesort=sizeoption?
Answer:No, that has exactly the same effect as the-Soption, and is prohibited.
Do we have to handle all theotherpossible flags of thelscommand? e.g.Do we have to consider the case where a user typesls_by_size.sh -r, which would be equivalent tols -r -S?
Answer:Thats not necessary, though if you do it correctly, that will be considered a bonus. You can obtain full marks if your script handles invocations of the formls_by_size.sh my_file(wheremy_fileis some file or directory).
Will our script take a list of files on standard input? Or will the user give them as command-line arguments to the script?
Answer:Ideally, your script will use command-line arguments as input i.e., you can imagine your script being invoked as something likels_by_size.sh file1 file2 . (Hint: you will need to work out how to do this, but its very similar to accessing arguments to a function.)However, if you are having difficulties with that, then you may instead assume a list of files is supplied to standard input, and this will be considered only a minor flaw in your solution. If you do this, then please add aREADMEtext file to your submission, stating thats what youve chosen to do.
Should we output the filenamesandsizes? Or just the filenames?
Answer:Ideally, your script will output just the filenames. E.g., if a user typesls_by_size.sh ., and there are three files calledsmall,mediumandlargein the current directory, of 1 MB, 5MB and 10MB size respectively, then your script should output:

large
medium
small
Correction: as per the man page, the-Sflag causes ls to sort indescendingorder.
However, if your output contains size information as well, that will be considered only a minor flaw.
Should we output the result in multiple columns, likelsdoes by default? Or can we output files one per line?
Answer:One per line.
Is there anything we can use to test script 1?
Answer:There is here is a script,test-q1.sh, which runs some basic tests on yourls_by_size.shscript. Put it in the same directory as yourls_by_size.shscript, and run it, and it will tell you if your script passes or fails those basic tests.
Question 2
How many words are in, say, the stringhttp://www.example.org/ch01s02?
Answer:Six words: http, www, example, org, ch and s.
Will we be supplied the name of a file as a command-line argument? Or can we assume it will always be calledunix-1969-1971.txt?
Answer:Your script should read a file that is, thecontentsof a file from standard input.
Is there a test script for question 2?
Answer:There is:test-q2.sh. This performs some verybasictests of your script can it be executed, and does it give the correct answer for some small inputs of up to five words length.
If you are unsure whether your script is getting the right answer for longer sample texts, you might like to try pasting them into the form atthis page. It wont tell you theexactword count, but it will let you know if you are close.
Question 3
What is the CSV file called that we need to use?
Answer:The current one is calledIDCJDW6111.201905.csv, and can be obtained from the link that says plain text version (4 kb).
Should we allow for the fact that the location of the.csvfile will change? For instance, Mays data is available from the URLhttp://www.bom.gov.au/climate/dwo/201905/text/IDCJDW6111.201905.csv, but Aprils was found athttp://www.bom.gov.au/climate/dwo/201904/text/IDCJDW6111.201904.csv, and presumably Junes will be athttp://www.bom.gov.au/climate/dwo/201906/text/IDCJDW6111.201906.csv.
Answer:If you like, you may hard-code the URL for the date of the current file, as at the date the project is submitted.Although, better practice would be to (for instance) check the date at the time the script is being run, and work out the appropriate URL to use.
Can our script make use of programs likewgetorcurlto download the data?
Answer:Yes, absolutely Bash has no way of downloading data from URLs itself,1so your script should certainly usewgetorcurlto do so.
What isYYY-MM-DDformat? Do you meanYYYY-MM-DD?
Answer:The later is correct, and Ive updated the specification. It means a format like2019-04-28, representing the 28th of April, 2019.
So we need to write two scripts?
Answer:You do.
Where does our second script,weather_analyser.sh, get its input from?
Answer:It should expect to receive lines on standard input, where each line contains two columns, separated by commas; the first column should be a date (inYYYY-MM-DDformat), and the second either the word unenjoyable or enjoyable.
For example:
2019-03-01,enjoyable
2019-03-02,unenjoyable
2019-03-03,enjoyable
This means your scripts could be put in a pipeline,weekends.sh | weather_analyser.sh, to get a single line of output, either supported or unsupported.
Should our second script,weather_analyser.sh, consider the months data as a whole? Or should it analyse each week separately?
Answer:Its up to you, but make sure you add some comments explaining why you chose the analysis you did. For instance, you might consider the percentage of weekdays that were enjoyable, versus the percentage of weekends that were enjoyable, and output the word supported when the former is higher. (Is that a good method of analysis? I leave it to you to decide.)
Is there a test script for question 3?
Answer:There is:test-q3.sh. This performs some basic tests of your two scripts for this question can they be executed, and do they give output in the correct format.

1.Well, it does in some versions see the StackExchange answer athttps://unix.stackexchange.com/posts/83927/revisions. But the better approach is still to usewgetorcurl.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] html graph 1. Reconstructingls
$25