Intermediate Unix: Difference between revisions

From 22118
Jump to navigation Jump to search
(Created page with "__NOTOC__ {| width=500 style="font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;" |Previous: None |Next: Python Recap and Objects |} You did do the Course preparation, right!! Otherwise all of this matters not. == Required course material for the lesson == Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/22113_01-Unix.ppt Introduction to Unix]<br> == Subjects covered == * New Unix commands * Scripting in bash == Exercises to be...")
 
mNo edit summary
Line 1: Line 1:
__NOTOC__
__NOTOC__
{| width=500  style="font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;"
{| width=500  style="font-size: 10px; float:right; margin-left: 10px; margin-top: -56px;"
|Previous: None
|Previous: Beginner Unix
|Next: [[Python Recap and Objects]]
|Next: [[Git 1]]
|}
|}
You did do the [[Course preparation]], right!! Otherwise all of this matters not.


== Required course material for the lesson ==
== Required course material for the lesson ==
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22113/22113_01-Unix.ppt Introduction to Unix]<br>
Powerpoint: [https://teaching.healthtech.dtu.dk/material/22118/22118_01-Unix.ppt Introduction to Unix]<br>


== Subjects covered ==
== Subjects covered ==
Line 23: Line 21:
# 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'''.
# 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?
# What is the path to the '''bash''' command?
# Write a bash shell script that solves exercise 19-24, 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 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.
# 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.



Revision as of 14:26, 7 November 2025

Previous: Beginner Unix Next: Git 1

Required course material for the lesson

Powerpoint: Introduction to Unix

Subjects covered

  • New Unix commands
  • Scripting in bash

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.

  1. Go back to exercise 2 & 3 in previous week. Check if the files are changed, using diff this time.
  2. 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.
  3. What is the path to the bash command?
  4. 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.
  5. 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.
  1. 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.

Exercises for extra practice