[R] grep in filename

Charles C. Berry cberry at tajo.ucsd.edu
Thu Oct 4 20:36:09 CEST 2007


On Thu, 4 Oct 2007, Alberto Monteiro wrote:

> Is there any version of grep that gets information from the filename?
>
> For example:
> x <- "myfile.txt"
> y <- grep.file("my text", x)
> should return in y the lines with my text.
>
> I know that
> x <- "myfile.txt"
> y <- grep("my text", readLines(x))
> will probably work, but maybe there's a more direct (and
> less memory hungry) option.

Let your system utilities handle the burden.

For *NIXes, this approach:

 	http://finzi.psych.upenn.edu/R/Rhelp02a/archive/101103.html

and Windows XP

 	http://finzi.psych.upenn.edu/R/Rhelp02a/archive/101220.html

Chuck

>
> Alberto Monteiro
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



More information about the R-help mailing list