home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / utlos2.zip / Doc / pattern.doc < prev    next >
Text File  |  1997-10-24  |  6KB  |  125 lines

  1. $Id: pattern.doc 1.6 1997/10/25 01:59:10 brian Exp $
  2.  
  3.                 pattern.doc : Filename pattern matching
  4.                            By: Brian E. Yoder
  5.  
  6.         (c) Copyright International Business Machines Corporation 1997
  7.         All rights reserved.
  8.  
  9. ========================================================================
  10. A dot is just another character. "*" means "all files" on all platforms
  11. ========================================================================
  12.  
  13. To the ls and other commands in this package, a filename is just a
  14. string of characters. The dot has no special meaning (it's just another
  15. character), so there is no concept of a "file extension". This is
  16. consistent with Win32, OS/2's HPFS, and with Unix filesystems.
  17.  
  18. The pattern * matches any filename. The pattern *.* matches any filename
  19. that contains a dot. Note that *.* will not match a filename that
  20. doesn't contain a dot! This is important to remember! It is the one
  21. Unix-like convention that has been carried over.
  22.  
  23. ========================================================================
  24. Path Separator : Both \ and / are accepted
  25. ========================================================================
  26.  
  27. Either a \ (backslash) or / (forward slash) character may be used as a
  28. filename path separator on the command lines of these utilities.
  29.  
  30. The \ (backslash) is traditionally used for the DOS, Windows, and OS/2
  31. platforms and is required by the native commands for those platforms.
  32. The / (forward slash) is the only path separator used for Unix platforms
  33. and is often required by the DOS, Windows, and OS/2 ports of the popular
  34. Unix-like GNU tools.
  35.  
  36. However, the DOS, Windows, and OS/2 programming interfaces allow both
  37. characters to be used as path separators. Therefore, the commands in
  38. this package are designed to accept either character as a path separator
  39. for maximum convenience no matter which platform or convention you need
  40. or prefer.
  41.  
  42. ========================================================================
  43. Patterns : Lots better than DOS, even better than Win32 and OS/2
  44. ========================================================================
  45.  
  46. A filename can contain one or more of the following patterns. Note that
  47. patterns are not case-sensitive:
  48.  
  49. Pattern      What it matches                    Examples
  50. -------      ------------------------------     ----------------------------
  51.  
  52.   *          Matches any string, including      *ab* matches ab, blab,
  53.              the null string.                   and babies.
  54.  
  55.                                                 * matches any string,
  56.                                                 including TEMP, WINDOWS,
  57.                                                 makefile, or myfile.c.
  58.  
  59.   ?          Matches any single character.      ab?c matches any filename
  60.                                                 that is 4 characters
  61.                                                 long, begins with ab,
  62.                                                 and ends with c.
  63.  
  64.   .          Remember that "." matches a dot    *.* matches myfile.c,
  65.                                                 config.sys, and zip.hlp
  66.  
  67.                                                 *.* does NOT match TEMP,
  68.                                                 WINDOWS, or makefile.
  69.                                                 This is because these
  70.                                                 names do not contain a
  71.                                                 dot character.
  72.  
  73.   [...]      Matches any one of the             [ABC]* matches any filename
  74.              enclosed characters.               that begins with A, B, or C.
  75.  
  76.   [.-.]      Matches any character              [A-Z]* matches any filename
  77.              between the enclosed pair,         that begins with a letter.
  78.              inclusive (range).
  79.                                                 [A-LN-Z]* matches any filename
  80.                                                 that doesn't begin with M.
  81.  
  82.   [!...]     Matches any single character       [!XYZ]* matches any filename
  83.              except one of those enclosed.      that does not begin with
  84.                                                 X, Y, or Z.
  85.  
  86. Put a backslash before the following characters if they are part of the
  87. filename to be matched. This removes their special meaning:
  88.  
  89.         [ ] { } !
  90.  
  91. ========================================================================
  92. In addition ...
  93. ========================================================================
  94.  
  95. Enclosed characters can be combined with ranges. Thus, [ABCM-Z]* matches
  96. any filename that begins with A, B, C, or M through Z.
  97.  
  98. Additionally, any pattern may be followed by:
  99.  
  100.     {m}      Matches exactly m occurrences of the pattern.
  101.     {m,}     Matches at least m occurrences of the pattern.
  102.     {m,n}    Matches at least m but no more than n occurrences of the pattern.
  103.  
  104.     where: m and n must be integers from 0 to 255, inclusive.
  105.  
  106. ========================================================================
  107. Examples
  108. ========================================================================
  109.  
  110. The pattern [A-Z][0-9A-Z.]{0,} matches any filename that begins with a
  111. letter that is followed only by letters or numbers, and may have a dot
  112. (DOS or OS/2 8.3 extension).
  113.  
  114. The pattern [!.]{1,} matches any filename that does not contain a dot.
  115. Literally, the pattern means: Match any name that contains one or more
  116. occurrences of any character that is not a dot.
  117.  
  118. The pattern *TXT* matches any filename that contains the string "TXT",
  119. either in the beginning, at the end, or in the middle.
  120.  
  121. Again, the pattern * matches any filename. The pattern *.* matches any
  122. filename that contains a dot. Note that *.* will not match a filename
  123. that doesn't contain a dot! This is important to remember! It is the one
  124. Unix-like convention that has been carried over.
  125.