Reputation: 1092
I have a list of filenames which look like this:
tRapTrain.Isgf3g.2853.2.v1.primary.RC.txt tRapTrain.Yox1.txt
tRapTrain.Isgf3g.2853.2.v1.primary.txt tRapTrain.Ypr015c.txt
tRapTrain.Isgf3g.2853.2.v1.secondary.RC.txt tRapTrain.Yrm1.txt
tRapTrain.Isgf3g.2853.2.v1.secondary.txt tRapTrain.Zbtb12.2932.2.v1.primary.RC.txt
Now i need to select the files with primary.txt and all the files where no final suffix is found. final suffix == primary.RC.txt , secondary.RC.txt, secondary.txt.
So my desired output will be:
tRapTrain.Isgf3g.2853.2.v1.primary.txt
tRapTrain.Yox1.txt
tRapTrain.Ypr015c.txt
tRapTrain.Yrm1.txt
I tried to do it with ls tRap*primary.txt
but cant figure out how to do both selections at once. Any help is appreciated.
Upvotes: 3
Views: 487
Reputation: 1296
You can use find:
find * -type f -not -name "*.secondary.RC.txt" -not -name "*.primary.RC.txt" -not -name "*.secondary.txt" -print
Upvotes: 2
Reputation: 17044
Using Shopt:
$ shopt -s extglob
$ ls !(*primary.RC.txt|*secondary.RC.txt|*secondary.txt)
Meaning:
!(pattern-list)
Matches anything except one of the given patterns.
Upvotes: 1
Reputation: 20225
I would use an inverted grep match:
ls tRap* | grep -v "\.RC\." | grep -v "\.secondary\."
This should get rid of anything with ".RC." or ".secondary." in the title, which sounds like what you want.
This may not be the most elegant, but it works.
Upvotes: 1