amber is a code search and replace tool written by Rust. This tool is inspired by ack, ag, and other grep-like tools.
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.
Download from release page, and extract to the directory in PATH.
Two commands (ambs
/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 --regex
.
ambs keyword // recursively search 'keyword' from the current directory.
ambs keyword path // recursively search 'keyword' from 'path'.
ambr keyword replacement // recursively search 'keyword' from the current directory, and replace to 'replacement' interactively.
ambr keyword replacement path // recursively search 'keyword' from 'path', and replace to 'replacement' interactively.
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.
Replace keyword? ( Yes[Y], No[N], All[A], Quit[Q] ):
grep --color=auto -r EXPORT_SYMBOL_GPL ./data/linux 0.27s user 0.41s system 37% cpu 1.825 total
ag --nogroup EXPORT_SYMBOL_GPL ./data/linux 1.19s user 2.84s system 167% cpu 2.404 total
pt --nogroup EXPORT_SYMBOL_GPL ./data/linux 3.37s user 0.94s system 228% cpu 1.883 total
ambs EXPORT_SYMBOL_GPL ./data/linux 2.55s user 0.81s system 179% cpu 1.872 total
grep --color=auto -r "Quick Search" ./data/jawiki-latest-pages-articles.xml 0.82s user 1.68s system 99% cpu 2.495 total
ag --nogroup "Quick Search" ./data/jawiki-latest-pages-articles.xml 15.38s user 0.89s system 100% cpu 16.265 total
pt --nogroup "Quick Search" ./data/jawiki-latest-pages-articles.xml 12.49s user 1.13s system 100% cpu 13.548 total
ambs "Quick Search" ./data/jawiki-latest-pages-articles.xml 5.83s user 10.82s system 2304% cpu 0.723 total