amber is a code search and replace tool written by Rust. This tool is inspired by ack, ag, and other grep-like tools.
Useful default settings
- Recursively search from the current directory
- Ignore VCS directories (.git, .hg, .svn, .bzr)
- Ignore binary files
- Output by the colored format
Large files ( > 1MB by default) are divided and searched in parallel.
amber can replace a keyword over directories (traditionally by
find ... | xargs sed -i '...') .
You can decide to do replacing or not interactively.
amber-search-git package from AUR.
Download from release page, and extract to the directory in PATH.
Two commands (
ambr) are provided.
ambs means "amber search", and
ambr means "amber replace".
The search keyword is not regular expression by default. If you want to use regular expression, add
amber replace interactively by default. If the keyword is found, the following prompt is shown, and wait. If you input 'y', 'Y', 'Yes', the keyword is replaced. 'a', 'A', 'All' means replacing all keywords non-interactively.
--regex option is enabled, regex captures can be used in
Default flags can be configured by
Available entries and default values are below:
You can choose some entries to override like below:
- CPU: Intel(R) Xeon(R) Gold 6134 CPU @ 3.20GHz
- MEM: 1.5TB
- OS : CentOS 7.5
- source1: https://github.com/torvalds/linux ( 52998files, 2.2GB )
- source2: https://dumps.wikimedia.org/jawiki/latest/jawiki-latest-pages-articles.xml.bz2 ( 1file, 8.5GB )
- pattern1( many files with many matches ) : 'EXPORT_SYMBOL_GPL' in source1
- pattern2( many files with few matches ) : 'irq_bypass_register_producer' in source1
- pattern3( a large file with many matches ) : '検索結果' in source2
- pattern4( a large file with few matches ) : '"Quick Search"' in source2
- amber (v0.5.1)
- ripgrep (v0.10.0)
- grep (v2.20)
- fastmod (v0.2.0)
- find/sed (v4.5.11/v4.2.2)
hyperfine with the following options.
--warmup 3: to load all data on memory.
- search (
|1||212.8ms ( 139% )||154.1ms ( 100% )||685.2ms ( 448% )|
|2||199.7ms ( 132% )||151.6ms ( 100% )||678.7ms ( 448% )|
|3||1.068s ( 100% )||4.642s ( 434% )||3.869s ( 362% )|
|4||1.027s ( 100% )||4.409s ( 429% )||3.118s ( 304% )|
- replace (
|1||792.2ms ( 100% )||1231ms ( 155% )||155724ms ( 19657% )|
|2||418.1ms ( 119% )||352.4ms ( 100% )||157396ms ( 44663% )|
|3||18.390s ( 100% )||74.282s ( 404% )||639.740s ( 3479% )|
|4||17.777s ( 100% )||74.204s ( 417% )||625.756s ( 3520% )|