home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / search.cmd < prev    next >
OS/2 REXX Batch file  |  1993-05-28  |  2KB  |  94 lines

  1. /**
  2. 17-Apr-93    Brust    first edit
  3.  
  4. @    Search.CMD
  5.  
  6. Function:    sucht Text in mehreren ASCII-Dateien
  7.  
  8. Aufruf von :    OS/2 Prompt
  9.  
  10. Parameter:    "Suchstring" Filenamen
  11. **/
  12.  
  13. parse arg string files sub
  14. parse source creater
  15. vernam="OS/2"
  16. versys=SysOS2Ver()
  17. datum=date()
  18. zeit=time()
  19. matchnr=0
  20. linenr=0
  21. call INIT
  22.  
  23. say word(creater,3)' at 'datum' 'zeit' under 'vernam' 'versys
  24. if files='' then files='*.*'
  25.  
  26. if string='' then signal usage
  27.  
  28. say yellow'searching for'red string normal'in'red files normal
  29.  
  30. if (sub='/S'  | sub='/s') then
  31.                 do
  32.                     call SysFileTree files, 'file', 'FS'
  33.                     dump=sysfiletree('*','dirnr','DS')
  34.                     say 'subdirectories are included'
  35.                 end
  36.             else
  37.                 do
  38.                     call SysFileTree files, 'file', 'F'
  39.                     dump=sysfiletree('*','dirnr','D')
  40.                 end
  41. if file.0 = 0 then 
  42.         do
  43.             say yellow'no files matching'red files yellow'found'normal
  44.             exit
  45.         end
  46. do i=1 to file.0
  47. datei=word(file.i,5)
  48. /** say cyan'searching in'red datei normal **/
  49. drop found.
  50. call SysFileSearch string,datei,'found.','N'
  51. if found.0 = 0 then
  52.         do
  53.             /** say yellow'no lines found matching'red string yellow'in'red datei normal  **/
  54.         end
  55.     else
  56.         do
  57.             say
  58.             say cyan'file 'datei' matched: 'normal
  59.             do t=1 to found.0
  60.                     say found.t
  61.                     linenr = linenr +1
  62.             end    
  63.             matchnr = matchnr +1
  64.         end
  65.  
  66. end
  67. say
  68. say 'a total of 'file.0' files and 'dirnr.0' directories are searched'
  69. if matchnr=0 then say 'no file matched'
  70. if matchnr=1 then say matchnr' file matched'
  71. if matchnr>1 then say matchnr' files matched'
  72. if linenr=0 then say 'no lines matched'
  73. if linenr=1 then say linenr' lines matched'
  74. if linenr>1 then say linenr' lines matched'
  75.  
  76.  
  77. drop i file found t 
  78. exit
  79.  
  80. USAGE:
  81. say 'Usage: 'yellow word(creater,3)' string [filenames [/S]]'normal
  82. say 'if no filename is given, *.* is assumed'
  83. say 'use /S to include sub-directories'
  84. say red'Note:'normal'textsearch is case sensitive'
  85.  
  86. exit
  87.  
  88. INIT:
  89. esc    = '1B'x          /* define ESCape character */
  90. red    = esc||"[31m"    /* ANSI.SYS-control for red foreground */
  91. yellow = esc||"[33m"    /* ANSI.SYS-control for yellow foreground */
  92. cyan   = esc||"[36m"    /* ANSI.SYS-control for cyan foreground */
  93. normal = esc||"[0m"     /* ANSI.SYS-control for resetting attributes to normal */
  94. RETURN