Software Carpentry
Shell Basics


You Can Skip This Lecture If...

The Shell

The Shell is Not the Operating Sytsem

The File System


Navigating the File System

Execution Cycle

Providing Options

Creating Files and Directories

Looking at Files

Basic Tools



Exercise 3.1:

Suppose ls shows you this:

Makefile    biography.txt   data    enrolment.txt   programs    thesis

What argument(s) will make it print the names in reverse, like this:

thesis  programs    enrolment.txt   data    biography.txt   Makefile

Exercise 3.2:

What does the command cd ~ do? What about cd ~hpotter?

Exercise 3.3:

What command will show you the first 10 lines of a file? The first 25? The last 12?

Exercise 3.4:

What do the commands pushd, popd, and dirs do? Where do their names come from?

Exercise 3.5:

How would you send the file earth.txt to the default printer? How would you check it made it (other than wandering over to the printer and standing there)?

Exercise 3.6:

The instructor wants you to use a hitherto unknown command for manipulating files. How would you get help on this command?

Exercise 3.7:

diff finds and displays the differences between two text files. For example, if you modify earth.txt to create a new file earth2.txt that contains:

Name: Earth
Period: 365.26 days
Inclination: 0.00 degrees
Eccentricity: 0.02
Satellites: 1

you can then compare the two files like this:

$ diff earth.txt earth2.txt
< Inclination: 0.00
> Inclination: 0.00 degrees
> Satellites: 1

(The rather cryptic header "3c3" means that line 3 of the first file must be changed to get line 3 of the second; "4a5" means that a line is being added after line 4 of the original file.)

What flag(s) should you give diff to tell it to ignore changes that just insert or delete blank lines? What if you want to ignore changes in case (i.e., treat lowercase and uppercase letters as the same)?

Send comments