Quote:
Originally Posted by
Kibou
Thank you, Don.
I am sorry, I forgot to mention that the string and data files were different files.
I am a little perplexed with the
grep -F solution. I had no idea that it could be used as an equivalent of the
| operator.
You still seem to be confused. The
-F option to the
grep utility has nothing to do with the
| extended regular expression special character.
The grep utility searches input files for a list of fixed strings (with the
-F option), extended regular expressions (with the
-E option), or basic regular expressions (when neither
-E nor
-F are given). The list can be specified with separate
-e options; by a single operand containing the list of expressions on separate lines; by using the
-f option to name a file containing strings, BREs, or EREs on separate lines in the file; or by a combination of any or all of the above.
There weren't any BRE or ERE special characters in your sample list of strings to be matched. When that is the case, you can either use fixed strings on separate lines or as separate
-e option arguments, or you can convert the fixed strings into an ERE using the
| ERE special character to separate the strings in a single ERE. With a large file or with a lot of strings, fixed string searches are likely to be much faster ERE evaluations.
When you see something suggested in these forums that you don't understand, look at the man pages (as clx suggested). If you can't figure out why it worked after reading the man pages, ask us to explain it. We want to help you learn how to use the tools available on UNIX and Linux systems. Note that the utilities available vary from system to system and the options that are available on a given utility also vary from system to system, so when you pose a problem or ask a question, tell us what operating system including the version of that operating system and what shell you're using so we can explain things that will work in your environment.