No matter what I try with cut, awk, sed, or grep, it orders by ID first only then last name then first name when it should go in order of last name so it instead should look like
f132b02: Kiara Acevedo
f132a01: Caleb Barn
but instead it orders it by ID and not alphabetical last name and output looks like this
f132a01: Barn, Caleb
f132b02: Acevedo, Kiara
the information from the folder I’m retrieving the information is extracted from “/etc/passwd” and is trying to order the IDs below
f132a01:Barn Caleb
f132a02:Casey Nathan
f132a03:Sanchez Ana
f132a04:Thomas Jeff
f132a05:Cavhill Jared
f132b01:Johnson Andrew
f132b02:Acevedo Kiara
f132b03:Felaccio Steven
f132b05:Blotner Sam
f132b06:Pereira Brian
The code I’ve been trying is down below:
username, first name, and last name
sed -E 's/(.*), (.*) (.*)/1 2 3/' |
sort -k3
echo
count=$(cut -d: -f1,5 /etc/passwd | grep f132 | wc -l)
echo "Number of students in the class: $count"