Installation • Command-line completion • Man documentation • Usage • CI Status • Contributing • License
path is a dead simple tool for working with paths. This tool provides commands which you can use to replace such tools as basename, dirname, and readlink and many more. But unlike these tools, path allows you to pass input not only as arguments, but also using standard input (for example with pipes). It's easy to use and doesn't require to know all this kung-fu with find or xargs.
Simple examples:
find . -iname '*.txt' -print0 | xargs -0 -n1 -- basename
# or
find . -iname '*.txt' | xargs -L1 -I{} basename "{}"
# with path
find . -iname '*.txt' | path basename# Note that there is two spaces between {} and \; and if you forget
# about this it will don't work. Also in this case we will run 'basename'
# for each item in find output.
find . -mindepth 1 -maxdepth 1 -type d -exec basename {} \;
# with path
find . -mindepth 1 -maxdepth 1 -type d | path basenameAlso, it works MUCH faster (~120x):
$ git clone https://github.com/kubernetes/kubernetes.git --depth=1
$ cd kubernetes
$ hyperfine 'find . -iname *.go -print0 | xargs -0 -n1 -- basename' 'find . -iname *.go | path basename'
Benchmark 1: find . -iname *.go -print0 | xargs -0 -n1 -- basename
Time (mean ± σ): 12.621 s ± 0.077 s [User: 5.871 s, System: 7.043 s]
Range (min … max): 12.512 s … 12.745 s 10 runs
Benchmark 2: find . -iname *.go | path basename
Time (mean ± σ): 106.5 ms ± 1.5 ms [User: 59.8 ms, System: 60.4 ms]
Range (min … max): 104.1 ms … 111.1 ms 28 runs
Summary
find . -iname *.go | path basename ran
118.45 ± 1.80 times faster than find . -iname *.go -print0 | xargs -0 -n1 -- basename
To build the path from scratch, make sure you have a working Go 1.24+ workspace (instructions), then:
go install github.com/essentialkaos/path@latest
From ESSENTIAL KAOS Public Repository for EL 8/9/10
sudo dnf install -y https://pkgs.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm
sudo dnf install pathYou can download prebuilt binaries for Linux and macOS from EK Apps Repository:
bash <(curl -fsSL https://apps.kaos.st/get) pathSince version 1.2.0 you can update path to the latest release using self-update feature:
path --updateThis command will runs a self-update in interactive mode. If you want to run a quiet update (no output), use the following command:
path --update=quietNote
Please note that the self-update feature only works with binaries that are downloaded from the EK Apps Repository. Binaries from packages do not have a self-update feature and must be upgraded via the package manager.
You can generate completion for bash, zsh or fish shell.
Bash:
path --completion=bash | sudo tee /etc/bash_completion.d/path > /dev/nullZSH:
path --completion=zsh | sudo tee /usr/share/zsh/site-functions/path > /dev/nullFish:
path --completion=fish | sudo tee /usr/share/fish/vendor_completions.d/path.fish > /dev/nullYou can generate man page using next command:
path --generate-man | sudo gzip > /usr/share/man/man1/path.1.gz| Branch | Status |
|---|---|
master |
|
develop |
Before contributing to this project please read our Contributing Guidelines.