[R] help with grep list files
r at catwhisker.org
Mon Feb 20 22:57:10 CET 2017
On Mon, Feb 20, 2017 at 03:41:50PM -0600, Glenn Schultz wrote:
> I have the following files in a directory and I would like only a list of those starting with “lld" and ending with “dat”. I used the following and it gives me the lld files
> list.files(path = readpath, pattern = "^lld[A-Z0-9]")
> to get just .dat files I tried
> list.files(path = readpath, pattern = "^lld[A-Z0-9].dat$”) but nothing is returned
> below is a dput from the first command. $ is an end of line anchor correct? What am I doing wrong?
Note that help(list.files) mentions (among other things):
| File naming conventions are platform dependent. The pattern
| matching works with the case of file names as returned by the OS.
Also, your pattern ("^lld[A-Z0-9].dat$") does not include the '_'
I was able to get the results you requested in my environment (FreeBSD
list.files(path = readpath, pattern = "^lld[_A-Z0-9]*.dat$")
(Note the '*' in there, as well.)
But "filename globbing" is not the same as "regular expressions," and as
the above-cited Note warns, results may well be platform-dependent, so
David H. Wolfskill r at catwhisker.org
How could one possibly "respect" a misogynist, racist, bullying con-man??!?
See http://www.catwhisker.org/~david/publickey.gpg for my public key.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 603 bytes
Desc: not available
More information about the R-help