ls
to list the contents of the directory you are inpwd
to print your working directorymkdir shell_excercises
to make a directory called shell_excercisescd shell_excercises
to change directory into the shell_excercises directorypwd
again to confirm the directory you are incd ..
to go up one directory from your current directorycd
, pwd
and ls
to navigate around your university home directory and find your filescd ~
to get back to your home directory (where you started when you first logged in)Before you start change directory to the shell_excercises directory you created in the excercises above
touch my_example_file.txt
to create an empty filenano my_example_file.txt
to open the file in the text editorcat my_example_file.txt
to show the contents of the example file in the promptcp my_example_file.txt second_file
to create a copy of the filecat second_file
to confirm the contents is the samemv second_file second_file.txt
to move (rename) the file to a new locationrm second_file.txt
to remove the file, it's a duplicate anywaywget http://www.soton.ac.uk/~pm5c08/unix/student_marks.tsv
to download a marks spreadsheetwc student_marks.tsv
to see the number lines, words and characters in the filegrep Wheeler student_marks.tsv
to find the marks for Patrick McSweeney. Think about other patterns you could use to produce the same resultfind ~
to list every file in your home tree. What would you do to list every file in /tmp ?find ~ | grep doc
to list all the word documents in your home tree. Think about what the short comings of this pattern might beman grep
to get some ideas for how you might might improve the pipeline in question 3head -n30 student_marks.tsv
to see the top 29 students marks. Now use head -n30 student > 29students.tsv
to make a .tsv of just the top 29 students. Why is it only the top 29 students?cut -f1 student_marks.tsv
to see a list of all the
students usernames. From this starting point add sort and uniq to the
pipe line to create a list of usernames which is sorted alphabetically
with the duplicates removed.Two PhD demonstrators have been marking some coursework. They have been sharing a combined marks spreadsheet for the class by email rather than using a shared drive. At some point they have become confused and have both been adding to different spreadsheets which started from the same email. To add to the confusion one of them sorted the spreadsheet into username while the other left it in its original sort. This is now your problem to fix. Write some shell scripts to create a copy of the original spreadsheet they both started from and a copy of the a spreadsheet of each demonstrators marks. The spreadsheets can be found at http://www.soton.ac.uk/~pm5c08/unix/demonstratorA.tsv and http://www.soton.ac.uk/~pm5c08/unix/demonstratorB.tsv
Write a python script that reads tsv data from the standard input and calculates the average of the marks fed into it. It should print the average to the standard output.
Create a pipeline which takes every spreadsheet (there should be 6) now in your shell_excercises directory and computes the class average. The script should take into consideration that some marks will be duplicated across different files. You should then also write a pipeline which tells you how many marks were used to calculate the average. Finally write a pipeline to spot students who's work has been marked twice by accident. How many students does this effect?