Saturday 16 December 2017

How can I use grep to show just filenames on Linux?

For a simple file search you could use grep's
-l and -r
options:




grep -rl
"mystring"


All the
search is done by grep. Of course, if you need to select files on some other parameter,
find is the correct solution:



find
. -iname "*.php" -execdir grep -l "mystring" {}
+


The
execdir option builds each grep command per each directory, and
concatenates filenames into only one command
(+).

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...