Please use Linux scripts or bash programming. This is Linux script class Assumin
ID: 3821521 • Letter: P
Question
Please use Linux scripts or bash programming. This is Linux script class
Assuming that you have a file comprising records (lines) for more than 100 employees Each record includes: (1) employee first name, (2) employee last name, (3) employee hourly wages, and (4) number of hours that employee worked a current week. Write an awk program that Outputs the header information stating "The list of employees working 40 or more hours." Assigns ORS (Output Record Separator) to be a dash (i.e. Outputs last names and hours of all employees that worked 40 or more hours (note, print only the last names and number of hours worked) Outputs the number of employees that worked more than 40 hours (e.g., The total number of employees that worked 40 or more hours is: D
Explanation / Answer
create a file employee_details.awk
paste below content
#!/bin/sh
awk -F "-" '
BEGIN { count=0; print "The list of employees working 40 or more hours."}
{if ($4 >= 40) {count=count+1; print $2" "$4}}
END{ print "The total number of employees that worked 40 or more hour is "count}' employee_details.txt
Please note change employee_details.txt above with the file name you have.
After saving file, run following
chmod +x employee_details.awk
./employee_details.awk
Sample output
file used:
fname1-lastnam1-5-45
fname2-lastnam2-5-38
fname3-lastnam3-5-45
fname4-lastnam4-5-40
fname5-lastnam5-5-45
fname6-lastnam6-5-37
fname7-lastnam7-5-45
fname8-lastnam8-5-20
fname9-lastnam9-5-45
output
The list of employees working 40 or more hours.
lastnam1 45
lastnam3 45
lastnam4 40
lastnam5 45
lastnam7 45
lastnam9 45
The total number of employees that worked 40 or more hour is 6