1 Parti. Bash shell scripting 3 #1. Write a Bourne Again Shell script (name it \
ID: 3788871 • Letter: 1
Question
1 Parti. Bash shell scripting 3 #1. Write a Bourne Again Shell script (name it "userinfo.sh") to do the following task: then (3) displays logi n name, user's name, uid and gid, e for user's home directory, and users default shell 7 cat passwdi.txt 18:544: S-1-5-18 Local Scgice: :19:544:U-NTAUTHORITYLoc alservice,S-1-5-19 10 Netatud Service: 20:544:U-NTAUTHORITYNetworkService,S-1-5-20: 11 44:544: S-1-5-32-544 12 Adruinistrakosi 500 513:U-richard-PCAdmin:/home/Administrator:bin/bash 13 Guest, 501:513:U-richard-PCWGuest:home/Guest:bin/bash 14 ichard 1000 513:U-richard. 15 iphp:::1010 600 John-Staff home/john:binsh 16 17 userinfo.sh richard 18 userid: richard. 19 uid: 1000 20 gid: 513 21 home directory: /hom shell: /bin/bash 24 Answer (copy and paste your auxer here) and mark it yellow (for background color. ccho -n "Enter a user name 31 32 33 35 37 exit 0 39 Paste here the screenshots or Terminal text or Session log ofthe run.Explanation / Answer
#!/bin/sh
echo "User id: $1"
uid=$(awk -F':' 'NR == 7{ print $3}' passwd1.txt)
echo "uid: $uid"
gid=$(awk -F':' 'NR == 7{ print $4}' passwd1.txt)
echo "gid: $gid"
homedirectory=$(awk -F':' 'NR == 7{ print $6}' passwd1.txt)
echo "homedirectory: $homedirectory"
shell=$(awk -F':' 'NR == 7{ print $7}' passwd1.txt)
echo "shell: $shell"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.