A helyes megoldás: # Search for noncomment (not # line) patterns listed in patterns.txt and search for them # one by one in text.txt and list matching lines alphabetically (and uniquely) grep -f <(grep -v ^# patterns.txt) text.txt |sort -u