linux - una - ls grep
¿Cómo puedo usar grep para mostrar solo nombres de archivos(sin coincidencias en línea) en Linux? (2)
Desde la página del manual de grep(1)
:
-l, --files-with-matches Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match. (-l is specified by POSIX.)
¿Cómo puedo usar grep
para mostrar solo nombres de archivos (sin coincidencias en línea) en Linux?
Usualmente estoy usando algo como:
find . -iname "*php" -exec grep -H myString {} \;
¿Cómo puedo obtener los nombres de archivo (con rutas), pero sin las coincidencias? ¿Tengo que usar xargs
? No vi una manera de hacer esto en mi página de manual de grep
.
La opción estándar grep -l
(que es una L minúscula) podría hacer esto.
Desde el estándar de Unix :
-l
(The letter ell.) Write only the names of files containing selected
lines to standard output. Pathnames are written once per file searched.
If the standard input is searched, a pathname of (standard input) will
be written, in the POSIX locale. In other locales, standard input may be
replaced by something more appropriate in those locales.
Tampoco necesita -H
en este caso.