11.4. Commenting and Filename Expansion

 <  Day Day Up  >  

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.

 <  Day Day Up  >  


UNIX Shells by Example
UNIX Shells by Example (4th Edition)
ISBN: 013147572X
EAN: 2147483647
Year: 2004
Pages: 454
Authors: Ellie Quigley

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