Workshop


The Workshop is designed to help you anticipate possible questions, review what you've learned, and begin learning how to put your knowledge into practice.

Quiz

1:

What is the functional difference between single quotation marks and double quotation marks when assigning values to variables?

2:

What special character causes the value of a variable to be substituted?

3:

How do you test for the existence of a directory in an if..then statement?

4:

In the statement for MYVAR in a b c d e; do, which begins a for..do loop, what values will the variable MYVAR hold?

5:

What do the caret (^) and dollar sign ($) characters do when used in a sed command?

Answers

A1:

When a value is assigned in single quotation marks (''), variable and command substitution are not performed even if a dollar sign ($) appears in the value. When a value is assigned in double quotation marks (""), variable and command substitution are performed before the value is assigned the variable.

A2:

The dollar sign ($).

A3:

if [ -d directory ]; then, where directory is the name or path of the directory you want to test for.

A4:

The commands inside the loop will be executed five times. The values of MYVAR each time through the loop will be "a", "b", "c", "d", and "e", in that order.

A5:

The caret matches the beginning of a line; the dollar sign matches the end of a line.

Activities

  1. Experiment with quoting and assigning values to variables and then expand them using the echo command. Do this until you feel familiar with the way variable assignment and substitution work.

  2. Study the final listing of the lxprint command until you feel confident that you understand how every line in it works.

  3. Try modifying the lxprint script to make sure that when the user passes a filename as an argument, it is a .tex file and not some other kind of file. (Hint: There are at least two ways to modify the script, both using command substitution and an if..then statement; one uses the grep command and the other uses sed.)



    SAMS Teach Yourself Red Hat(r) Fedora(tm) 4 Linux(r) All in One
    Cisco ASA and PIX Firewall Handbook
    ISBN: N/A
    EAN: 2147483647
    Year: 2006
    Pages: 311
    Authors: David Hucaby

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