Intermediate Unix
| Previous: Beginning Unix | Next: Git on command line |
Required course material for the lesson
Powerpoint: Introduction to Unix
Subjects covered
- New Unix commands
- Scripting in bash
Preparation for next week
You must create a github account if you do not have one already. Please consider a professional choice of username as it will follow you for a long time.
Sign up here: https://github.com/ Top right corner.
Exercises to be handed in
Use a text editor to to create a file mycommands.txt where you write all commands and observations you do in the following exercises. Use copy/paste to copy the commands. As you are doing some scripting then simply include your scripts into the mycommands.txt.
Note: Make sure that we can easily see which exercise you attempt to solve.
Note: You should work from your home directory, or a work directory that you specify explicitly in the top of your hand-in.
Note: Data files can be found in the collection of files.
- Go back to exercise 2 & 3 in previous week. Check if the files are changed, using diff this time. First try diff directly after the copy. Then use nano to make a change in myfile.acc and use diff again. See the difference. Understand how the change is reflected in the output.
- In the myfile.acc (copy of ex1.acc) change all occurrences of SPC to BLNK, using sed. Check if the files are changed, using diff.
- What is the path to the bash command?
- Use the history together with grep to find the bc calculation you did last week.
- Write a bash shell script that solves exercise 19-24 from last week, with the exercises clearly separated and explained in both the script and the output. "42" is unclear, but "Number of genes: 42" is clear. This should be straight forward (but long), especially since you wrote down what you did.
- Write a bash shell script that puts all the positive numbers in the file ex1.dat into a file ex1.pos2, and all the negative numbers into a file ex1.neg2. Column position does not matter. The script must clean up after itself, so if any temporary files are used, they must be deleted as the last action. Put the date and a description of the files in the first lines of the resulting output files.
- Last week you made the ex1.tot file in exercise 18. Using that file as input, write a bash shell script which finds the highest number in each number column and writes the corresponding swissprot identifier into the file highest.txt. That file should contain exactly 3 identifiers - one on each line.
- Same as previous exercise, except this time you need the identifiers for the second highest number and the output file is called 2highest.txt.
- Write a bash shell script that calculates the total number of lines for all files in the directory mentioned on the command line as argument. No argument means current directory. Misleading hint: cut can split on other than tab.