December 19, 2018

Connect to the server

Remember that you can connect to the server by opening the page

https://rstudio.iu.edu.tr:4200/

If the browser warns you about “Your Connection is not private”, just ckick “Advanced” and “Proceed”

Change your working directory to quiz4

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

nano quiz4.sh

The file last.txt contains information about who connected to the server in the last month

This time try to finish the quiz without opening a second connection to the server

How many lines are there in last.txt?

289

How many times each user has connected?

Use an AWK array to count each user separately

buse.azm 3
fustunel 3
anaraven 61
berkay_e 2
kadir_mi 7
kelifklc 6
kadeertu 9
alpaslan 12
hilal_ca 10
busrabal 3

Which users forgot to disconnect?

If the line says gone or down, it means that the user did not exit the session correctly.

Show who did forgot to disconnect

kelifklc
andres
ziyabay1
kadeertu
alpaslan
hilal_ca
cansutun
ziyabay1
ziyabay1
mevlutge

How many minutes lasted each connection?

The last column gives the connection time in (hh:mm) format.

Use a regular expression to select only lines that match this format.

Use the split() command to obtain hours and minutes.

Print the first and last columns, and the total of minutes

gamzemer (00:30) 30
anaraven (00:11) 11
fustunel (00:19) 19
ansevili (00:22) 22
aayden (00:26) 26
busrabal (01:11) 71
ansevili (01:03) 63
aayden (02:14) 134
edasmlgl (03:51) 231
anaraven (00:01) 1

How many minutes lasted each connection?

In some cases last column gives may be (d+hh:mm)

Use a regular expression to select only lines that match this format.

Use the split() command to obtain hours and minutes.

Print the first and last columns, and the total of minutes

gamzemer (1+00:03) 1443
aayden (3+23:44) 5744
esengul (3+23:43) 5743
ziyabay1 (1+02:49) 1609
ziyabay1 (1+02:38) 1598
hilal_ca (1+02:41) 1601
ecenaz.y (1+02:37) 1597
ssohn199 (1+02:42) 1602
ssohn199 (1+02:39) 1599
kadeertu (1+02:47) 1607

Combine the last two awk commands into a single one

Ignore the lines that say gone or down

gamzemer (00:30) 30
anaraven (00:11) 11
fustunel (00:19) 19
ansevili (00:22) 22
aayden (00:26) 26
busrabal (01:11) 71
ansevili (01:03) 63
aayden (02:14) 134
edasmlgl (03:51) 231
anaraven (00:01) 1

Combine the last answer with the second one

Show how many minutes each person was connected in the last month

buse.azm 93
fustunel 232
anaraven 1205
berkay_e 244
kadir_mi 1096
kelifklc 2490
kadeertu 1957
alpaslan 4373
hilal_ca 4999
busrabal 286