Select a file from the file list… here is a solution to the problem.
Select a file from the file list
I have a list of filenames as shown below:
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 that didn’t find the final suffix. Final suffix == primary. RC.txt , secondary. RC.txt, secondary.txt.
So the output I want would be:
tRapTrain.Isgf3g.2853.2.v1.primary.txt
tRapTrain.Yox1.txt
tRapTrain.Ypr015c.txt
tRapTrain.Yrm1.txt
I tried doing it with ls tRap*primary.txt
, but didn’t know how to do both. Thanks for your help.
Solution
You can use Find:
find * -type f -not -name "*.secondary. RC.txt" -not -name "*.primary. RC.txt" -not -name "*.secondary.txt" -print