1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Find A File Installed By Brew as a unix til

This commit is contained in:
jbranchaud
2021-04-13 15:31:27 -05:00
parent 42ee326715
commit 95cb87045b
2 changed files with 35 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
_1114 TILs and counting..._
_1115 TILs and counting..._
---
@@ -1048,6 +1048,7 @@ _1114 TILs and counting..._
- [Exclude Certain Files From An rsync Run](unix/exclude-certain-files-from-an-rsync-run.md)
- [Figure Out The Week Of The Year From The Terminal](unix/figure-out-the-week-of-the-year-from-the-terminal.md)
- [File Type Info With File](unix/file-type-info-with-file.md)
- [Find A File Installed By Brew](unix/find-a-file-installed-by-brew.md)
- [Find Files With fd](unix/find-files-with-fd.md)
- [Find Newer Files](unix/find-newer-files.md)
- [Fix Unlinked Node Binaries With asdf](unix/fix-unlinked-node-binaries-with-asdf.md)

View File

@@ -0,0 +1,33 @@
# Find A File Installed By Brew
I installed a homebrew formula to satisfy a dependency for a Rails application.
Related to [the whole mimemagic
debacle](https://github.com/rails/rails/issues/41750), I had run [`brew install
shared-mime-info`](https://formulae.brew.sh/formula/shared-mime-info). The
specific file that Rails needed from this install was `freedesktop.org.xml`.
It took me two commands to figure out if that file had been included and where
it was living.
The first was to find the _brew prefix directory_ — the place where homebrew
had installed everything related to `shared-mime-info`.
```bash
$ brew --prefix shared-mime-info
/usr/local/opt/shared-mime-info
```
Now that I know about that directory, I can use
[`fd`](https://github.com/sharkdp/fd)—a more user-friendly alternative to
`find`—to _find_ the specific file in that directory. Not wanting to cast too
narrow of a net, I decided to look for any `xml` file in that directory.
```bash
$ fd -e xml . /usr/local/opt/shared-mime-info
/usr/local/opt/shared-mime-info/share/shared-mime-info/packages/freedesktop.org.xml
```
The `-e` flag specifies the file extension. The `.` is the first argument, the
pattern to look for. In this case, anything. The second argument
(`/usr/local/opt/shared-mime-info`) is the path to look within. In this case,
the brew prefix for the `shared-mime-info` package.