Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grep this and NOT that?

Tags:

regex

r

I am trying to return a file name from list.files, but there are 2 similarly named files. filename.csv filename_review.csv

I want to put each file name into its own list. Doing that for filename_review.csv is easy since it has unique stuff in it, but how do I sift out the other? I need to grep(".csv", list.files()) without getting filename_review.csv returned.

like image 903
James Avatar asked Dec 17 '22 10:12

James


1 Answers

Showing all files in the working directory that has a csv extension but not ends in review could be done:

setdiff(list.files(pattern='.csv$'), list.files(pattern='review.csv$'))
like image 160
daroczig Avatar answered Jan 04 '23 22:01

daroczig