mirror of
https://github.com/jbranchaud/til
synced 2026-01-06 16:48:01 +00:00
Add Get Matching Filenames As Output From Grep as a unix til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
[til.hashrocket.com](https://til.hashrocket.com/).
|
||||||
|
|
||||||
_760 TILs and counting..._
|
_761 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -687,6 +687,7 @@ _760 TILs and counting..._
|
|||||||
- [File Type Info With File](unix/file-type-info-with-file.md)
|
- [File Type Info With File](unix/file-type-info-with-file.md)
|
||||||
- [Find Newer Files](unix/find-newer-files.md)
|
- [Find Newer Files](unix/find-newer-files.md)
|
||||||
- [Forward Multiple Ports Over SSH](unix/forward-multiple-ports-over-ssh.md)
|
- [Forward Multiple Ports Over SSH](unix/forward-multiple-ports-over-ssh.md)
|
||||||
|
- [Get Matching Filenames As Output From Grep](unix/get-matching-filenames-as-output-from-grep.md)
|
||||||
- [Get The Unix Timestamp](unix/get-the-unix-timestamp.md)
|
- [Get The Unix Timestamp](unix/get-the-unix-timestamp.md)
|
||||||
- [Global Substitution On The Previous Command](unix/global-substitution-on-the-previous-command.md)
|
- [Global Substitution On The Previous Command](unix/global-substitution-on-the-previous-command.md)
|
||||||
- [Globbing For All Directories In Zsh](unix/globbing-for-all-directories-in-zsh.md)
|
- [Globbing For All Directories In Zsh](unix/globbing-for-all-directories-in-zsh.md)
|
||||||
|
|||||||
21
unix/get-matching-filenames-as-output-from-grep.md
Normal file
21
unix/get-matching-filenames-as-output-from-grep.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Get Matching Filenames As Output From Grep
|
||||||
|
|
||||||
|
Standard use of the [`grep`
|
||||||
|
command](http://man7.org/linux/man-pages/man1/grep.1.html) outputs the lines
|
||||||
|
that match the specified pattern. You can instead output just the names of
|
||||||
|
the files where those matches occur. To do this, include the `-l` flag.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ grep -Rl hashrocket .
|
||||||
|
./elixir/run-exunit-tests-in-a-deterministic-order.md
|
||||||
|
./git/show-file-diffs-when-viewing-git-log.md
|
||||||
|
./git/single-key-presses-in-interactive-mode.md
|
||||||
|
./internet/enable-keyboard-shortcuts-in-gmail.md
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
This recursive grep finds all the files where `hashrocket` appears. It only
|
||||||
|
looks for the first match in a file, so each file will only be listed once
|
||||||
|
even if there may have been multiple matches.
|
||||||
|
|
||||||
|
See `man grep` for more details.
|
||||||
Reference in New Issue
Block a user