On 30-Sep-08 14:36:04, bioinformatics_guy wrote: > I want to make sure this piece of code I wrote is doing what > I want it to do. > > ll<-function(string) > { > grep(string,dir(),value=T) > } > > subdir = ll("Coverage_[1-9][0-9]$") > > I basically wrote a little function that would grab all the > files of form Coverage_[0-99] > > The way I wrote it, will it grab Coverage_5 or does it have to have 2 > numbers (10-99)?
I think you want "Coverage_[1-9]*[0-9]$", since your form will only match "Coverage_mn" where m is one of 1-9 and n is one of 0-9. The "*" means "zero or any number of ... ". Example (command-line grep in Linux): grep 'Coverage_[1-9]*[0-9]$' << EOT > Coverage > Coverage_5 > Coverage_01 > Coverage_19 > Coverage_19q > EOT Coverage_5 Coverage_19 Note that this does not catch "Coverage_01" because "[1-9]" does not include "0". Use "[0-9]" here as well if you need this. Hoping this helps, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 30-Sep-08 Time: 16:43:01 ------------------------------ XFMail ------------------------------ ______________________________________________ R-help@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.