This is an old question, but the current answers are incorrect :)
Use yum whatprovides, with the absolute path to the file you want (which may be wildcarded). For example:
yum whatprovides '*bin/grep'
Returns
grep-2.5.1-55.el5.x86_64 : The GNU versions of grep pattern matching utilities.
Repo : base
Matched from:
Filename : /bin/grep
You may prefer the output and speed of the repoquery
tool, available in the yum-utils
package.
sudo yum install yum-utils
repoquery --whatprovides '*bin/grep'
grep-0:2.5.1-55.el5.x86_64
grep-0:2.5.1-55.el5.x86_64
repoquery
can do other queries such as listing package contents, dependencies, reverse-dependencies, etc.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…