Exercises

Lecture 4 Scripting Challenge

Create a script called sortpeople.sh that sorts a list of people by their last names. For example, when we run the script ./sortpeople.sh names.txt, where names.txt contains the following:

Ada Lovelace
Rachel Carson
Hypatia Alexandria
it prints
Alexandria
Carson
Lovelace

You should use three commands, piped togetheer using the | symbol. You should use cat and sort and well as either cut or awk. Use man pages and/or Google to look up how to use these commands and what options you might need.

You can find a list of names here. For background on these names, check this out (scroll down).

A fully completed script will include error checking for the input argument, and be used as an executable. However, it might be useful to test the commands at the command line first.