frep is a fast find-and-replace tool. Search and replace in files in a directory (including subdirectories), or process stdin.
Warning
This project is deprecated. You can use scooter with the --no-tui flag instead - for example:
# Instead of:
frep "before" "after"
# Use:
scooter -N -s "before" -r "after"When specifying a directory:
# Instead of:
frep --directory ./src/dir "before" "after"
# Use:
scooter -N -s "before" -r "after" ./src/dirRun scooter --help to see all flags.
To replace text in files within the current directory:
frep "before" "after"Or specify an alternative directory:
frep --directory ./src/dir "before" "after"To process text from stdin:
$ echo "hello world" | frep "hello" "hi"
hi worldThere are a number of command-line flags to change the behaviour of frep, such as:
--fixed-strings(-f) to search without regex--advanced-regex(-a) to use advanced regex features such as negative lookahead (not enabled by default for improved performance)--include-files(-I) and--exclude-files(-E) to include or exclude files and directories using glob matching. For instance,-I "*.rs, *.py"matches all files with the.rsor.pyextensions, and-E "env/**"excludes all files in theenvdirectory--case-insensitive(-i) to ignore case when matching--match-whole-word(-w) to only match complete words
Run frep --help to see the full list of flags.
Note: When processing stdin, the --include-files, --exclude-files, and --hidden flags are not available as they are file-system specific.
frep is fast. Below is a benchmark for comparison, performing a find and replace across the entire Linux kernel repo, finding and replacing the string "before" with "after":
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
frep |
4.402 ± 0.032 | 4.363 | 4.446 | 1.00 ± 0.03 |
ripgrep + sd |
4.916 ± 0.130 | 4.792 | 5.122 | 1.12 ± 0.04 |
fastmod |
4.398 ± 0.109 | 4.219 | 4.493 | 1.00 |
fd + sd |
10.011 ± 0.000 | 10.010 | 10.011 | 2.28 ± 0.06 |
On macOS and Linux, you can install frep using Homebrew:
brew install thomasschafer/tap/frepDownload the appropriate binary for your system from the releases page:
| Platform | Architecture | Download file |
|---|---|---|
| Linux | Intel/AMD | *-x86_64-unknown-linux-musl.tar.gz |
| Linux | ARM64 | *-aarch64-unknown-linux-musl.tar.gz |
| macOS | Apple Silicon | *-aarch64-apple-darwin.tar.gz |
| macOS | Intel | *-x86_64-apple-darwin.tar.gz |
| Windows | x64 | *-x86_64-pc-windows-msvc.zip |
After downloading, extract the binary and move it to a directory in your PATH.
Ensure you have cargo installed (see here), then run:
cargo install frepEnsure you have cargo installed (see here), then run the following commands:
git clone git@github.com:thomasschafer/frep.git
cd frep
cargo install --path frep --locked