I want to do the equivalent of ls
in R
.
Say I want ls /a/b/c/201*/*/d/e/f/*/sameNameFile.gz
, this command take 5 seconds to run on a terminal, I tried to use list.files
but it takes a path
argument and need recursive=TRUE
. It is taking ages...
Is there a function I could use (or an option to list.files
) that would allow me to run this ls
command (I know I can run the comamnd itself with system(cmd,intern=TRUE)
but I want a R solution)
The result from the related question
Fast test if directory is empty
was that on some systems, system("ls -f -R", intern = TRUE)
is faster than list.files
. Your performance may vary.
The -R
switch means recursive; the -f
switch means don't sort alphabetically, which is where the performance gain comes from.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With