grepath is a command-line utility to effortlessly extract file paths from command outputs. It's especially useful in pipelines for processing compiler or lint tool outputs.
- Extract file paths from a given text.
- Optionally extract full paths including line and column numbers.
- Remove duplicate paths.
brew install kqito/tap/grepath
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/kqito/grepath/releases/latest/download/grepath-installer.sh | sh
Or download directly from releases.
When we run grepath <file>
, it reads the file and outputs the paths from the text.
For example, if you want to open error files in VSCode, you can use the following command:
grepath error.log | xargs -o code
You can use grepath
in command-line pipelines to filter paths from the output of other commands. Here is an example usage:
cat error.log | grepath | xargs -o code
grepath --help
Usage: grepath [<file>] [-d] [-l] [-u]
Args
Positional Arguments:
file file
Options:
-d, --debug help
-u, --unique unique Omit duplicate paths
--help display usage information
- Support for windows paths
- Support for custom regex patterns
Contributions, issues, and feature requests are welcome! Feel free to check the issues page if you want to contribute.
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)