[R] help with grep list files

Glenn Schultz glennmschultz at me.com
Mon Feb 20 22:41:50 CET 2017


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?


c("lld022017_AB7755_AS0038.dat", "lld022017_AS0039_AS5210.dat", 
"lld022017_AS5211_AS7917.dat", "lld022017_AS7918_AT8661.dat", 
"lld022017_AT8662_AW6667.dat", "lld022017_AW6668_AZ3066.dat", 
"lld022017_AZ3067_BC9534.dat", "lld022017_BC9535_MA2230.dat", 
"lld022017_MA2231_MB0288.dat", "lld022017.zip")

	[[alternative HTML version deleted]]

More information about the R-help mailing list