I have a couple of big text files and in the file UNIQS.txt I have a list of strings to grep from another file. The code I use isgrep -f UNIQS.txt EEP_VSL.uniqs.sam > UNIQ_templates.samwhich does nothing - the file generated is empty. But when I dogrep -F -f UNIQS.txt EEP_VSL.uniqs.sam > UNIQ_templates.samit works correctly. This confuses me because I didn't think grep would interpret the entries in UNIQS.txt as regexp patterns without quotes and slashes and so on being in the file (which there aren't). Is it the case in general that if you are getting the patterns from a file then it will automatically think that they are regexp patterns?Edit: In the UNIQS.txt file, there are newline separated strings of the formHWI-ST365:215:D0GH0ACXX:2:1101:10034:186783(called template names) and the file EEP_VSL... tab separated columns, with about 14 columns and the first column is the template name, so basically I want to extract the line corresponding to each template in the file.
Reading grep patterns from a file
grep
The -f option specifies a file where grep reads patterns. That's just like passing patterns on the command line (with the -e option if there's more than one), except that when you're calling from a shell you may need to quote the pattern to protect special characters in it from being expanded by the shell.The argument -E or -F or -P, if any, tells grep which syntax the patterns are written in. With no argument, grep expects basic regular expressions; with -E, grep expects extended regular expressions; with -P (if supported), grep expects Perl regular expressions; and with -F, grep expects literal strings. Whether the patterns come from the command line or from a file doesn't matter.Note that the strings are substrings: if you pass a+b as a pattern then a line containing a+b+c is matched. If you want to search for lines containing exactly one of the supplied strings and no more, then pass the -x option.