Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with Linux!! 5.4) Based on Lab 7, Handouts 7 (example 1), and HW 7, please create a file called myloginfile as shown below
Need help with Linux!!
5.4) Based on Lab 7, Handouts 7 (example 1), and HW 7, please create a file called myloginfile as shown below and then write an awk script called mylogincheck to check on file myloginfile to see who spent less than one (1) hour on the system and then display those login records. (The last column of the output shown below indicates the time spent on the system).
$ last wi | grep "Mar 31 | head -5 > myloginfile
$ cat myloginfile
cfs264sp1809 pts/5 73.228.165.183 Sat Mar 31 21:36 - 21:46 (00:10)
cfs264sp1809 pts/4 73.228.165.183 Sat Mar 31 20:55 - 23:15 (02:20)
cfs264sp1809 pts/3 73.228.165.183 Sat Mar 31 20:10 - 22:25 (02:14)
ics311sp1820 pts/3 71.220.2.81 Sat Mar 31 19:07 - 19:07 (00:00)
cfs264sp1809 pts/6 73.228.165.183 Sat Mar 31 17:09 - 19:22 (02:13)
$
$ awk f mylogincheck myloginfile
cfs264sp1809 pts/5 73.228.165.183 Sat Mar 31 21:36 - 21:46 (00:10)
ics311sp1820 pts/3 71.220.2.81 Sat Mar 31 19:07 - 19:07 (00:00)
$
a) Please provide your script below (hint: Example 1 in AWK Handouts for week 7 can be used as a template)
b) Please provide the screenshot below:
5.5) Please use the solution to HW 7, hands-on problem 2, as a template to write a shell/awk script, called mymiddle3, that reads in three (3) numbers and then uses a self-defined function to determine the middle number in value. The middle number should be displayed in the main script, not inside the function you define. Please use the following testing cases to test your script:
$ ./mymiddle3 5 3 8
The middle number is 5.
$
$./mymiddle3 -2 -9 -7
The average is -7.
$
$ ./mymiddle3 8 3 8
The middle number is 8.
$
$ ./mymiddle3 0 -1 -1
The middle number is -1.
$
a) Please provide your script below along with a screenshot of the execution of the script:
b) Please provide the screenshot below:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started