/courses/cs100/cs197/USERNAME repository path for svn checkout command: /courses/cs100/cs197u/USERNAME/svn;
3. Copy the assignment files into this local copy with this command: cp -r /courses/cs100/cs197u/cs197u/assignments/assign-5/* /courses/cs100/cs197u/USERNAME/assign-5/svn
4. Add the files to the repository using the svn add command
5. Commit the changes to repository using the svn commit command
grep -no "[aeiouAEIOU]" text/hamlet.txt | awk -F":" 'BEGIN{x=1; y=0} { if(x!=$1) {print "x " x " has " y " y"; x = $1; y = 1} else y += 1}' | less
Note: grep -no is short for grep -n -o.
1. On the web, read about if statements in awk, and spend some time understanding what the command above does. Run the full command from within your assign-5 directory, so that it finds text/hamlet.txt. Use less after each pipe to understand what the code does. The anonymous variable names x and y are intentional to not make it obvious what the code is doing. Figuring out what they stand for is part of the task. Describe in 1 sentence what this command actually prints out. Write your answer into answers.txt. Don't use any variable names in your description.
2. Redirect the output of the above command into a file (instead of piping it to less as above). Use the sort command with some flags to sort this file in decreasing order of y. What is the largest x value for the largest y value? Which command did you use? Write your answers into answers.txt.
3. Don't add any output files to the SVN repository. Just commit your changes to answers.txt to the SVN repository
You will know that you have successfully committed files if you get a message which ends with: Committed revision <some number>.
./script.sh | less and study the code to understand what it does. Look up the tr command in man and on the web for this.
2. Edit the script so that instead of text/alice.txt it takes in the first command line argument. Add code that will check whether the first command line argument is set. If it is set, the line with the tr command should be run. If no argument is given, print out "Need file as argument 1" and do nothing further. Run your script with different files as input, such as text/hamlet.txt for testing the encryption.
3. Edit script.sh further to take the key as a second command line argument. Also add code that does the following: If "-" is given as second argument, use the default key in script.sh, otherwise change the key to use the second command line argument. Run your script with different keys for testing.
4. Edit script.sh with a third command line argument (which acts as a flag):
a.) Add code so that the flag can be set to "encrypt" for encrypting the file with the key, and to "decrypt" for decrypting;
b.) Add code so that for any other string given as the third argument (or if it is missing), the code should do nothing;
c.) Add code for the "decrypt" case: if the flag is set to "decrypt", decrypt an encrypted text back to lower-case using the key.
Run your code to verify that encryption and decryption work correctly. Note that for running decryption, you should first run "encrypt" and save the output to a file, and then use that as input with the "decrypt" flag next time. What happens if your key is shorter than the alphabet, or if it contains duplicate letters?
5. Don't add any output files to the SVN repository. Just commit your changes toscript.sh to the SVN repository.
neat.sh to make it print out some information about yourself and your files. See neat.sh for exact directions. Again, you may have to use man, earlier lectures, and the web for help with accomplishing the tasks. This is what the output should look like (approximately):
Hi test197u!
Right now it is Fri Jan 27 12:55:56 EST 2012.
The host name of this Elnux node is: elnux1.cs.umass.edu
The current directory you are in has 4 files.
Here is a long listing of the files:
--------------------------------------
total 20
-rwxr-x--- 1 test197u grad 4372 Jan 27 12:53 answers.txt
-rwxr----- 1 test197u grad 1578 Jan 27 12:55 neat.sh
-rwxr----- 1 test197u grad 155 Jan 27 13:28 script.sh
drwxrwxrwx 2 test197u grad 4096 Jan 27 12:34 text
--------------------------------------
1 of these files are directories.
Here is some information about this text directory:
-----------------------------------------------------
Num. of lines: 3735 text/alice.txt
Num. of words: 29461 text/alice.txt
File size: 168K text/alice.txt
Num. of lines: 7067 text/hamlet.txt
Num. of words: 33598 text/hamlet.txt
File size: 196K text/hamlet.txt
Num. of lines: 5803 text/jungle_book.txt
Num. of words: 53856 text/jungle_book.txt
File size: 296K text/jungle_book.txt
The total size of the text directory in KB is 664K text
That's it for today. Bye!
2. Save the output into a file named output.txt
3. Add output.txt to the SVN repository.
4. Commit your changes so the files are uploaded to the repository.