December 12, 2019

Change your working directory to quiz2

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

nano quiz2.sh

For each of the next questions, please write the corresponding commands after the question

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

Write the awk command to show the first 5 lines of world2017.txt

Afghanistan asia    653000  31700000    1810
Albania europe  28800   2920000 10500
Algeria africa  2380000 38300000    13300
Angola  africa  1250000 26000000    6190
Antigua_and_Barbuda americas    440 97800   18900

Show the data between lines 45 and 50 (inclusive) of world2017.txt

Denmark europe  42900   5640000 44600
Dominican_Republic  americas    48700   10300000    11900
Ecuador americas    256000  15700000    10700
Egypt   africa  1000000 89800000    9810
El_Salvador americas    21000   6250000 7640
Equatorial_Guinea   africa  28100   1080000 32700

Write the awk command to show the data corresponding to Turkey

Turkey  europe  785000  75800000    21700

Write the awk command to find how many lines are there in world2017.txt

178

How many countries are called “Rep”?

Write the command to find how many lines of world2017.txt contain the exact word “Rep”, but not “Republic”

Congo,_Dem._Rep.    africa  2340000 71300000    685
Congo,_Rep. africa  342000  4750000 5320

Which is the African country with more than 100 million habitants?

Nigeria africa  924000  172000000   5480

Write an awk command that prints population and country (in that order) when the continent is “Europa”

2920000 Albania
2890000 Armenia
8580000 Austria
9390000 Azerbaijan
9480000 Belarus
11200000 Belgium
3600000 Bosnia_and_Herzegovina
7270000 Bulgaria
4280000 Croatia
1140000 Cyprus
10600000 Czech_Republic
5640000 Denmark
1320000 Estonia
5440000 Finland
63900000 France
4050000 Georgia
81300000 Germany
11300000 Greece
9840000 Hungary
327000 Iceland
4680000 Ireland
59700000 Italy
2040000 Latvia
3000000 Lithuania
545000 Luxembourg
2080000 Macedonia,_FYR
423000 Malta
4070000 Moldova
627000 Montenegro
16800000 Netherlands
5080000 Norway
38300000 Poland
10500000 Portugal
20100000 Romania
144000000 Russia
8920000 Serbia
5430000 Slovak_Republic
2070000 Slovenia
46700000 Spain
9620000 Sweden
8130000 Switzerland
75800000 Turkey
45100000 Ukraine
64600000 United_Kingdom

Which are the countries with the biggest population in Europa?

Sort the output of the last command, from biggest to smallest

Use | and sort

144000000 Russia
81300000 Germany
75800000 Turkey
64600000 United_Kingdom
63900000 France
59700000 Italy
46700000 Spain
45100000 Ukraine
38300000 Poland
20100000 Romania
16800000 Netherlands
11300000 Greece
11200000 Belgium
10600000 Czech_Republic
10500000 Portugal
9840000 Hungary
9620000 Sweden
9480000 Belarus
9390000 Azerbaijan
8920000 Serbia
8580000 Austria
8130000 Switzerland
7270000 Bulgaria
5640000 Denmark
5440000 Finland
5430000 Slovak_Republic
5080000 Norway
4680000 Ireland
4280000 Croatia
4070000 Moldova
4050000 Georgia
3600000 Bosnia_and_Herzegovina
3000000 Lithuania
2920000 Albania
2890000 Armenia
2080000 Macedonia,_FYR
2070000 Slovenia
2040000 Latvia
1320000 Estonia
1140000 Cyprus
627000 Montenegro
545000 Luxembourg
423000 Malta
327000 Iceland

What is the ranking of Turkey’s population in Europe?

Take the sorted output of last command and pipe it into an awk command that prints the row number, the second, and the first field, when the country is “Turkey”

3 Turkey 75800000

What is the ranking of Turkey’s GDP per capita in Europe?

Repeat the last command, changing “Population” for “GDP per capita”

29 Turkey 21700

How many countries are there in Europe?

Write an awk command that counts how many lines have “europe” in the second field

44