My current solution:
#!/bin/sh
while read file2
do
grep $file2 file1
done
the contents of file1 will be something like:
atlanta,blue,20090805
newyork,blue,20090805
washington,blue,20090805
dallas,blue,20090805
jacksonville,blue,20090805
the contents of file2 will be something like:
newyork
dallas
jacksonville
and the desired output to a file would be something like:
newyork,blue,20090805
dallas,blue,20090805
jacksonville,blue,20090805
when seeking a subset of a large list based on names from a second list, what is the best way to do something like this? any recommendations would be appreciated!
Thanks,
What about…
for your example case, it should work just like your loop does; and it should apply to the same range of cases to which both your verbal description and your loop do (one “name” per line in the “second list” file, i.e., no punctuation which
egrepmight misinterpret).