Previous Section  < Day Day Up >  Next Section

11.4. Commenting and Filename Expansion

Filename expansion is a mechanism that allows the user to type part of a filename and press the Esc key to see the rest of the filename(s). In the following examples, [Esc] represents the Esc key.

Example 11.20.

    (Press the Esc Key for [Esc].



1   $ ls a[Esc]=

    1) abc

    2) abc1

    3) abc122

    4) abc123

    5) abc2

2   $ ls a[Esc]*

    ls abc abc1 abc122 abc123 abc2

    abc   abc1  abc122 abc123 abc2

3   $ print apples pears peaches

    apples pears peaches

4   $ print [Esc]_

    print peaches

    peaches

5   $ print apples pears peaches plums

    apples pears peaches

6   $ print [Esc]2_

    print pears

    pears


EXPLANATION

  1. By typing an a, followed by the Esc key and an equal sign (=), all files starting with an a are numbered and listed. (The numbers do not serve any special purpose.)

  2. By typing an a, then the Esc key and an asterisk (*), the filenames starting with an a are displayed.

  3. The print command displays its arguments: apples, pears, and peaches.

  4. The Esc key, followed by an underscore (_), is replaced with the last argument.

  5. The print command displays its arguments: apples, pears, and peaches.

  6. The Esc key, followed by the number 2 and an underscore, is replaced by the second argument. The command (print) is the first argument, starting at word zero.

    Previous Section  < Day Day Up >  Next Section