2 USING: kernel fry io io.files io.encodings.ascii sequences
3 regexp command-line namespaces ;
9 ! TODO: case-insensitive
11 : grep-lines ( regexpt -- )
12 '[ dup _ matches? [ print ] [ drop ] if ] each-line ;
14 : grep-file ( pattern filename -- )
15 ascii [ grep-lines ] with-file-reader ;
18 "Usage: factor grep.factor <pattern> [<file>...]" print ;
24 unclip ".*" dup surround <regexp> swap [
27 [ grep-file ] with each