-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Sundar
Dorai-Raj
Sent: Thursday, November 04, 2004 6:39 AM
To: ramasamy at cancer.org.uk
Cc: R-help
Subject: Re: [R] list files ignoring the case option
Adaikalavan Ramasamy wrote:
Sorry if this is a question more on regular expressions. I
with several files which have been badly named. For example
are given either the extensions txt, TXT or Txt. I wish to
those files ending with 'txt' ignoring case.
Here is how I would do it in bash (Redhat FC2) :
touch a1.txt a2.TXT a3.Txt txt.control TXT.control
ls -1 | grep -i "txt$"
Here is how I am currently doing it in R
a <- list.files(all.files=T)
grep( "txt$", a, ignore.case=T, value=T )
Is it possible for me to modify the following line to include ignore
case option ?
a <- list.files( pattern="txt$" )
Thank you.
Regards, Adai
Not much of a regexpr guy myself, but the following should work:
list.files(pattern = "[tT][xX][tT]$")
There's probably a better answer though.
--sundar