Learning Objectives

After this lesson, students will be able to:

  • recognize the elements of the unix shell
  • will be able to use paths to files and directories
  • understand the difference between absolute and relative paths

Day 1

Intro

Working With Files and Directories (50 min)



Day 2

Pipes and filters (35 min)

IN-CLASS ACTIVITIES

A) Go into teams of 2 or 3 people. Find a name for your team and write it down in the etherpad along with the names of the team members. Take 5-7 min to do so.

B) Read https://swcarpentry.github.io/shell-novice/04-pipefilter/index.html and run along the example code on the terminal (as well as the exercises!). Email the code to your instructor once you are done. You can email the code as a .txt file or directly on the body of the email.

C) As you read, discuss with your team and answer:

1) what does the command wc do?

2) what do the options -l, -m, and -w from the wc command do?

3) How do you escape a waiting command?

4) What symbol do you use to redirect output to a file instead of printing it to the screen?

5) What does the cat command do?

6) What does sort -n do?

7) What command can you use to confirm that a file exists?

8) What is the main difference between the cat and less commands?

9) What happens if you redirect the output of a command operating on a file to the same file?

10) What does the symbol >> do?

11) What is the main difference between the commands head and tail?

12) What symbol do you use to pass the output of a command as input of the next command?

13) What is a pipeline?

14) What is the main difference between redirecting and piping an output?

15) What does the uniq command do?