UNIX Commands Exercises

Before doing these exercises be sure to read : CommandLineCrashCourse.pdf

Necessary files to complete this exercise.

You can play around with these files as much as you like. If you change or destroy them, just download them again.

Note: All the following actions should be done through the terminal. It is not all commands that have been covered in class or the reading material, so you will have to search for how to solve some of the problems. You are welcome to work together but you all have to do the exercises individually.

Setup

In order to do these exercises you need to download the files above. CD into the directory with the downloaded files, and then run the following docker command to start up a container with the exercises files included in that container.

	$ docker run -it --rm -v ${PWD}:/docs ubuntu

In the Ubuntu instance you now have access to through your terminal you should see the exercises files in the docs folder.

Exercises

  1. Start by creating a directory (folder) where all the exercise files will be placed. You decide where, but a good place would be on your desktop, or in your document directory.

  2. Create a file with the name to_be_deleted.txt

  3. delete the file to_be_deleted.txt

  4. Move the 3 exercise files into this directory.

  5. Use a text editor (VS Code is good choise) to create a file called mycommands.txt where you write all commands and observations you do in the following exercises. Use copy/paste to copy the commands. from the terminal to your text file.

  6. First list the files in the directory.

  7. Copy ex1.acc to myfile.acc.

  8. Look at the content of both files to ensure they are identical.

  9. Copy ex1.dat to myfile.acc.

  10. Check that the content of myfile.acc changed.

  11. Delete myfile.acc.

  12. Make a directory test and move the three files to it.

  13. Make a directory data and move the three files to that instead.

  14. Remove test directory.

  15. Change directory to data and confirm that you succeded.

  16. Go back to the home directory or work directory afterwards.

  17. Make three new directories “newtest” - one inside the other, like a russian doll.

  18. Move the data directory to the innermost “newtest” directory.

  19. Confirm that the three files are moved along with the data directory.

  20. Copy the three files to your home (your top directory).

  21. Remove all newtest directories and data in the with a single command.

  22. Count the lines in ex1.acc and ex1.dat.

  23. Concatenate ex1.acc and ex1.dat in the file ex1.tot, i.e. copy the content of two files into one new file. Verify that all gene IDs comes first followed by numerical data.

  24. Merge/Paste ex1.acc and ex1.dat together in ex1.tot, thus destroying the old file. Verify that corresponding gene IDs and numerical data are put on the same line. as the data.

  25. Extract (cut) SwissProt ID and 3rd numerical data (column 1 and 5) from ex1.tot. Put results into a file ex1.res.

  26. Find the 3 SwisProt ID’s in ex1.res which have the largest number(s) in column 2, i.e. the top 3 entries.

(c) 2016 by Peter Wad Sackett, pws@cbs.dtu.dk (ed. clbo@kea.dk 2019)