I am using the function grep -f inputfile searchfile As a result however I get the data sorted and all duplicates are removed. But this is actually not what I want and I cannot find a way to prevent this. Is there a way I get the exact same order as in the inputfile?
I don't understand why grep is doing this because in my memory this should not be happening. What could I do wrong here?
An example: my inputfile looks like (first few lines shown):
Moraceae Poaceae Fagaceae Rosaceae Betulaceae Salicaceae My search file looks like (first few lines shown):
Acanthaceae 0 1 0 1 1 0 10 0 10 1 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 Adoxaceae 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Aizoaceae 0 0 0 0 3 0 0 0 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Amaranthaceae 0 1 0 0 7 0 5 0 4 1 0 0 6 0 0 0 0 0 0 0 1 4 0 0 0 The output looks like (first few lines shown):
Acanthaceae 0 1 0 1 1 0 10 0 10 1 0 0 0 0 0 0 0 0 0 0 1 2 0 0 0 Aizoaceae 0 0 0 0 3 0 0 0 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Amaranthaceae 0 1 0 0 7 0 5 0 4 1 0 0 6 0 0 0 0 0 0 0 1 4 0 0 0 Amaryllidaceae 0 1 0 0 6 1 11 0 6 4 2 0 0 0 0 0 0 0 0 0 1 8 0 0 0 Anacardiaceae 0 1 0 0 0 0 20 0 7 0 0 1 0 0 0 0 0 0 0 0 1 10 0 0 0 The names are printed in red, meaning that they were matching.But I want to retrieve the exact same order and occurence as my inputfile, starting with "Moraceae". Any ideas?
Thanks a lot in advance!
inputfileshould contain the regular expressions that you want to look for insearchfile?