Question: Use a while loop to read each line in the file modified_etc_passwd directly and process each line as follows: Use a combination of the echo
Use a while loop to read each line in the file modified_etc_passwd directly and process each line as follows:
Use a combination of the echo and cut commands to assign the contents of the home directory field of the current record to a variable called homedir
Use a combination of the echo and cut commands to assign the contents of the username field to a variable called username
If homedir exists as a directory o Use a combination of the echo and cut commands to assign the contents that appears before the + of the GECOS field to a variable called fullname o If /home/STUDENTS/majors/username exists
Echo fullname and append to the file majors.txt Example: echo $fullname >> majors.txt o Otherwise
If /home/STUDENTS/nonmajors/username exists
Echo fullname and append to the file nonmajors.txt
Otherwise
Echo username and append to the file not_student.txt
Otherwise o Echo the current record and append to the file no_homedir.txt When finished, execute your script and create 4 clear output files.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
