Chapter Review


[Page 333]

Checklist

In this chapter, I described:

  • the creation of a C shell startup file

  • simple variables and lists

  • expressions, including integer arithmetic

  • aliases and the history mechanism

  • several control structures

  • job control

  • several new built-in commands

Quiz

1.

Why do you think integer expressions must be preceded by an @ sign?

2.

What's a good way to correct a simple typing mistake on the previous command?

3.

What's the function of the {} metacharacters?

4.

What character can you type to complete a filename on the command line?

5.

Describe the differences between the set and setenv built-in commands.

6.

How do you protect files from accidental overwrites?

7.

What command is used to lower the priority of a process?

8.

How do you protect scripts from Control-C interrupts?

Exercises

1.

Modify the junk utility from this chapter so that it is menu driven. [level: easy]

2.

Write a utility called hunt that acts as a front end to find; it takes the name of a file as its single parameter and displays the full pathname of every filename that matches, searching downward from the current directory. [level: medium]

Projects

1.

Write a Bash script called mv (which replaces the GNU utility mv) that tries to rename the specified file (using the GNU utility mv), but if the destination file exists, instead creates an index number to append to the destination file, a sort of version number. So if I type:

$ mv a.txt b.txt


but b.txt already exists, mv will move the file to b.txt.1. Note that if b.txt.1 already exists, you must rename the file to b.txt.2, and so on, until you can successfully rename the file to a name that does not already exist. [level: medium]

2.

Study the current trends in object-oriented programming and then design an object-oriented shell. [level: hard]




Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net