December 12, 2018

Change your working directory to quiz3

There is a file quiz3.sh in your folder. You will edit it with nano

nano quiz3.sh

For each of the next questions, please write the corresponding commands after the question. Data is on the file population_total.csv

If you like, you can open a second connection to the server

What is the total sum of the last field of each line of population_total.csv?

7595618719

What is the average of the last field of each line of population_total.csv?

3.87532e+07

What is the standard deviation of the last field of each line of population_total.csv?

Standard deviation is the square root of the average of the squares minus the square of the average

\(\sqrt{\sum x_i^2/n -(\sum x_i/n)^2}\)

1.44157e+08

What is the sum of all fields in each line of population_total.csv?

Print the first field and the sum from the second until the last field

geo 418071
Afghanistan 1821590000
Albania 279593000
Algeria 2249290000
Andorra 3693700
Angola 1257910000
Antigua and Barbuda 10420200
Argentina 2764950000
Armenia 297897000
Australia 1503897000

What is the average of all fields in each line of population_total.csv?

Modify the previous command to print average instead of sum. Skip the first line

Afghanistan 8.31776e+06
Albania 1.27668e+06
Algeria 1.02707e+07
Andorra 16866.2
Angola 5.74388e+06
Antigua and Barbuda 47580.8
Argentina 1.26253e+07
Armenia 1.36026e+06
Australia 6.86711e+06
Austria 5.84342e+06

Pivot table: Transform the table from one row to multiple rows

Show only the data for Turkey

Turkey 9770000
Turkey 9790000
Turkey 9800000
Turkey 9820000
Turkey 9830000
Turkey 9850000
Turkey 9860000
Turkey 9880000
Turkey 9890000
Turkey 9910000

Modify the previous command to print only the last 5 values

Show only the data for Turkey

Turkey 77000000
Turkey 78300000
Turkey 79500000
Turkey 80700000
Turkey 81900000