For UNIX please use the file addr to answer the three questions 1. Write a scrip
ID: 3587073 • Letter: F
Question
For UNIX please use the file addr to answer the three questions
1. Write a script file to print the Last Name, First Name and email address of a student with a header and a footer.
2. Refer to the file groups and print the list of user names and their groups. Use a script file with a header and footer
3. Refer to the file groups and write an awk script file which would accept a userID input and display the group name for that userID as output.
(file addr)
Addr (Column 1 – LastName, Column2: First name, Column3: email address, Column4: phone number, Column5: zip code)
Hilton,Tom,thilton@asu.com,85281345,543781,imap987648790
Potter,Harry,hpotter@hogworts.edu,853645555,875234
Granger,Herminone,hgranger@hogworts.edu,9856017638,334567
Moe,Elizi,emoe@asu.com,3892000109,345678
Ta,Ma,mata@asu.edu,6747829191,85281
Five,Jackson,jfive@asu.edu,7839209871,78339
Bean,Sean,sbean@asu.edu,56783908156,78648
Turner,Sophie,sturner@asu.edu,6784937689,9873329
Explanation / Answer
1.
#! bin/sh
echo "HEADER"
echo "Script to get the lastname,firstname,e-mail of the students"
echo "Last_name,First_name,e-mail"
awk -F "," '{print $1,$2,$3}' data.txt
echo "FOOTER"
echo "`date`"
2.
#! bin/sh
echo "HEADER"
echo "Script to get the list of user names and their groups"
echo "Group User"
awk -F':' '{print $1,$4}' /etc/group
echo "FOOTER"
echo "`date`"
3.
BEGIN {
print "Enter the user name: "
getline name < "-"
}
$4 == name {
print $4,$1
}
Run the awk script like below:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.