Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Write a script that displays all usernames and their UIDs in the following fashion:
2. Relevant commands, code, scripts, algorithms:
grep, cut, id, echo, for…do…done
3. The attempts at a solution (include all code and scripts):
I managed to list usernames and UIDs but I can't figure out how to add "uid=" string. I've been coming back to this problem for the last two days but maybe my approach is wrong. Please, help
Since I don't have a Solaris or Linux on PC, I've tested the code on tutorialspoint/execute_ksh_online.
From the given relevant commands I think the teacher or the course makers want to just cut one item from the passwd, process it in a for-do-done loop, and in the loop grep the item in the passwd again in order to get the second item.
But this is less efficient compared to piping the pair of items to awk or a while read loop.
The latter can directly split into variables if the field separator IFS is set accordingly. You do not even need to run cut before.
The Following User Says Thank You to MadeInGermany For This Useful Post: