read, echo, printf
Assignment 9
- Write a script called read1 that will ask the user to enter a username,
then display information about that user.
Display the username, UID, and home directory. Hint: /etc/passwd
contains the username (field 1), UID (field 3), home directory (field 6).
- Write a script called read2 that will display information about each user on the system.
Display one line per user containing: the username, UID, and home directory.
- Write a script called read3 the same as above but will add the name of each of the users groups.
Hint 1: /etc/group file contains group name (field 1) and names of users that belong to that group (field 4).
A user can belong to more than one group.
Hint 2: Loop on the lines of /etc/passwd and inside the loop look for groups for each user.
- Change the last script (call it read4) to format the output so that each column has enough width,
the UID is right justified, and the other fields are left justified.