For this exercise I wanted to give you some real-world examples of useful bash scripts. Therefore, you will write a couple of scripts that I actually use in my teaching to automate clerical tasks. To begin, please copy this (ficitious) classlist.txt to your directory, and note that it contains a list of usernames.
bholly
bjones
bscott
dgatton
dhathaway
jbonham
jcroce
jdenver
jhendrix
jjoplin
jmorrison
kcobain
mhutchence
oredding
pcline
rbuchanan
rrhoads
rwaters
svaughan
wwilliams
Write a script called addnames that is to be called as follows, where classlist is the name of the classlist file, and username is a particular student's username.
./addnames classlist username
The script should
1. print a message stating that the name already existed, or
2. add the name to the end of the list.
Hint: Use a for-loop to process each line in the file. To create a list of lines in the file, remember that you can use any bash construct inside a script that you can use in the terminal window. How would you list the lines of the file in the terminal window? Similarly, how would you append a particular item to the end of an existing file from the terminal window?