#!/bin/bash # one solution to day 3 activity # # CS 50, Fall 2022 # Tim Pierson, 2022 # #set variable to point to password file so we don't have to keep typing the #whole path f=/thayerfs/courses/22fall/cosc050/workspace/activities/day3/passwd echo "Using file: $f" echo echo "#1. Output the list of user full names, sorted alphabetically (remove duplicated occurrences of identical names)" cut -d : -f 5 < $f | sort | uniq echo echo "#2. Count the number of users with ‘James’ as the first name." grep 'James' $f | wc -l #or better #grep -c 'James' $f echo echo "#3. count the number of different shells used by all users." cut -d : -f 7 $f | sort | uniq | wc -l echo echo "#4. output the number of users using each type of shell in the descending order." cut -d : -f 7 $f | sort | uniq -c | sort -nr