Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help4407


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting (CITS4407).

A reminder that there will be no Zoom laboratory session on Friday 29th.
 
Assignment 2 and Clarifications.
 
Options:
RSS cloud
Jump to:

Question 3 in Exercise2

1 of 339 articles shown, currently no other people reading this forum.
photo
From: Christopher M.
Date: Fri 20th Mar, 2:24pm
Actions: 
        Login-to-reply
"Khushboo Soni"                               wrote:

> I'm trying to solve Q3 in Exercise 2. As you may know that we have some lines of text 
> in Feb2019 weather data. My first question is do we use TAIL/HEAD command to remove 
> some rows or is there some other command to do that. I thought we could use CUT 
> command for chopping rows but I haven't yet found the specific option to do so. 

Keep in mind that cut performs a vertical cut - it just saves the required (vertical) 
columns that we want.  cut cannot be used to request which (horizontal) lines we want.

Instead, we can use grep to select just the (horizontal) rows that we want.
All of the rows that we want need to have a common pattern, and that pattern should not be 
in any of the lines we don't want.


> At the moment I'm using tail -28 for Feb2019 and tail -29 for Feb2020 but may be 
> there is a better way to do this.

Those solutions will probably work, but they are not very general.
For example you had to know if a year was a leap year, and then use the exact number of days 
in February.
Moreover, if the questions asked about January, it would be neither 28 or 29.

Instead, can you find a pattern common to all of the required lines,
and then use grep to select just thos elines?
 
> Also do we have to calculate average of the column to determine which month is 
> hotter/wetter or are we just comparing?

Actually I should have marked that last part (your question) as 'super hard', at this stage.
If you know how to perform some calculations on the numbers in columns, then you could 
already do that, but it is harder.  Possible tools to use may be awk, dc, or even python, 
but don't put too much effort into it at this stage!

Good luck.

Related articles

Question 3 in Exercise2 (both) RSS
├─ original   Fri 20th Mar, 1:58pm, Khushboo S.
└─ THIS   Fri 20th Mar, 2:24pm, Christopher M.
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020