Re: Slickest way to do "joins"/lookups in text files
On Fri, Dec 17, 2004 at 08:39:37PM -0500, William Ballard wrote:
} In SQL you join tables. If it's indexed it's fast.
} Can you do this using text files from the prompt?
}
} Example:
} I'd like to investigate the most popular RSS readers Debian offers.
}
} $apt-cache search rss | cut -d' ' -f1 > rss.txt
} $wget http://popcon.debian.org/main/by_vote.gz
}
} I'd like to "filter" by_vote.gz to just the package names
} in "rss.txt". In SQL this would be a join. I'd like it
} to be "fast". Do I have to do this in SQL?
When you are matching whole words, and those words are each alone on a
line, you can use fgrep -f, as in:
zcat by_vote.gz | fgrep -f rss.txt
It isn't a general tabular join solution, but it works pretty well for this
particular purpose.
--Greg
Reply to: