Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Newbie: Grep question

 [1/5] from: kpeters::mvinc::net at: 12-Jul-2004 12:55


Hi list ~ what is a simple way to obtain a list of text files containing a certain string from a directory ? Thanks, as always, for any help! Kai

 [2/5] from: andreas:bolka:gmx at: 13-Jul-2004 1:12


Monday, July 12, 2004, 9:55:28 PM, Kai wrote:
> what is a simple way to obtain a list of text files containing a > certain string from a directory ?
simple-grep: func [ pattern [any-string!] dir [file!] /local files ] [ remove-each file files: read dir [ not find/any read join dir file pattern ] ] -- Best regards, Andreas

 [3/5] from: warp:reboot:ch at: 13-Jul-2004 1:28


result: copy [] list: read %. string: "a" foreach item list [if find item string [append result item]] Will) On 12 lug 2004, at 21:55, Kai Peters wrote:

 [4/5] from: warp:reboot:ch at: 13-Jul-2004 1:34


Wops, sorry Kai, I just reread your question, my example actually looks in the file name not its content. Will. On 12 lug 2004, at 21:55, Kai Peters wrote:

 [5/5] from: brock:kalef:innovapost at: 13-Jul-2004 9:55


This may help you out a little - not the most efficient algorithm, but provides a very simple little gui to select the directory to search. Also outputs a list of files found as well as displaying the files as they are found in the console window. rebol[] ; find only directory portion of path - exclude file name data-src: request-file/only/title "Select any File from the Data Folder to Process" "Open" data-src: first split-path data-src result-list: copy [] find-text: request-text/default "Enter text to find" change-dir data-src files: read %. print ["File containing: " :find-text newline] foreach file files[ cnt: 0 data: read/lines file foreach d data[ if all[find d find-text cnt = 0][ print [file "^-^-FOUND"] append result-list file cnt: cnt + 1 ] ] ] halt Cheers, Brock