Home How can I use grep to show just filenames (no in-line matches) on Linux?
Reply: 0

How can I use grep to show just filenames (no in-line matches) on Linux?

user8140
1#
user8140 Published in September 19, 2018, 6:46 pm

How can I use grep to show just file-names (no in-line matches) on Linux?

I am usually using something like:

find . -iname "*php" -exec grep -H myString {} \;

How can I just get the file-names (with paths), but without the matches? Do I have to use xargs? I didn't see a way to do this on my grep man page.

share|improve this question
  • 2
    You mean, you want the filenames that have at least one match? – leonbloy Jul 9 '11 at 22:27
  • 4
    Great question. I actually started using this to open a list of files returned by grep in Vim. vim $(grep -rl Something app/) – David Tuite Mar 20 '13 at 10:49
  • 1
    You cannot list files using grep command, it is basically used to fetch desired text from a file or a list. For instance, ps aux | grep 'apt-get' or grep 'text-to-find' /path/to/file/ – iamjayp Mar 17 '17 at 8:09

3 Answers 3

active oldest votes
up vote 1174 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.397621 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO