What Are Modern CLI Tools?
grep, find, and cat have been terminal staples for decades. They are still powerful, but their options are finicky, they are slow on large repositories, and their output is crude. Tools recently rewritten in languages like Rust do the same jobs faster, with more sensible defaults, and with nicer output.
| Classic tool | Modern replacement | Key difference |
|---|---|---|
grep | rg (ripgrep) | Fast, automatically respects .gitignore, recursion by default |
find | fd | Concise syntax, colored output, fast search |
cat | bat | Syntax highlighting, line numbers, Git change markers |
| (none) | fzf | Interactive fuzzy finder — combine with other commands |
It is better to treat these as complements you reach for first in day-to-day work, rather than as full "replacements" for the classic tools.
Installation
# macOS (Homebrew)
brew install ripgrep fd fzf bat
# Debian / Ubuntu
sudo apt install ripgrep fd-find bat
# fzf to
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install
# Arch
sudo pacman -S ripgrep fd fzf batOn Debian/Ubuntu, package name conflicts mean fd is installed as fdfind and bat as batcat. Adding alias fd=fdfind and alias bat=batcat to ~/.bashrc is convenient.
ripgrep (rg) — Code Search That Replaces grep
rg searches directories recursively, automatically excluding .gitignore, .ignore, and hidden files. That makes it a good fit for codebase search with no extra flags.
# grep method: + + set
grep -rn --color "TODO" .
# rg method:
rg TODOCommonly used options:
rg "fetchUser" -t js # JavaScript file (-t )
rg "error" -i # when
rg "config" -g "*.yaml" # glob file
rg "deprecated" -l # file
rg "handler" -A 3 -B 1 # 1, 3
rg "v\\d+\\.\\d+" -o #
rg --hidden --no-ignore "key" # file·when fileto| Item | grep | ripgrep (rg) |
|---|---|---|
| Recursive search | needs -r | default |
| Respects .gitignore | no | automatic |
| Speed | average | very fast (parallel) |
| File type filter | none | -t js, -t py |
| Default output | monochrome | color and line numbers |
fd — File Search That Replaces find
find is highly expressive but verbose. fd makes the most common patterns short and intuitive.
# find:
find . -type f -name "*.log"
# fd: ( , )
fd "\\.log$"
fd config # configCommonly used options:
fd -e log # log (-e)
fd -t f report # file (-t f), -t d
fd -H secret # file (-H)
fd -I node_modules # .gitignore when (-I)
fd pattern src/ #
fd -e tmp -x rm {} # run (-x, find -exec )| Item | find | fd |
|---|---|---|
| Default syntax | must specify -name, -type | pattern only |
| Matching | exact/glob | partial match and regex |
| .gitignore | not respected | automatically respected |
| Output | monochrome | color-coded |
| Command execution | -exec ... \; | -x / -X |
bat — File Viewer That Replaces cat
bat prints files like cat, but adds syntax highlighting, line numbers, and Git change markers. If the output is longer than the screen, it automatically pipes into a pager (less).
bat src/app.js # +
bat -p log.txt # plain ( without, cat)
bat -A config.txt # · when when
bat -r 10:30 server.log # 10~30
bat -l yaml deploy.tpl # setTo keep color inside a pipe, use --color=always.
rg -l "TODO" | xargs bat| Item | cat | bat |
|---|---|---|
| Syntax highlighting | none | yes |
| Line numbers | only with -n | default |
| Git diff display | none | change-line markers |
| Paging | none | automatic (less) |
| Script-friendly output | as-is | same with -p |
bat is a tool for human reading. If you need plain text in a script or a pipe, use -p (plain) or just cat. Decorative characters mixed into the output can break downstream processing.
fzf — Interactive Fuzzy Finder
fzf is a different kind of tool from the ones above. It is a universal filter that lets you interactively narrow down (fuzzy-match) a list from standard input and pick an item. It shines when you combine it with the output of other commands.
# file vim
vim $(fzf)
# fd Result fzf bat
fd -t f | fzf --preview 'bat --color=always {}'
# git after
git branch | fzf | xargs git checkout
# quit
ps -ef | fzf | awk '{print $2}' | xargs killAs you type, it matches even if the substring is scattered; then you pick a candidate with the arrow keys and press Enter.
Shell Integration — Where the Real Speed Comes From
fzf's install script registers shell keybindings and completion. Add the following to ~/.bashrc or ~/.zshrc.
# bash
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
# zsh
[ -f ~/.fzf.zsh ] && source ~/.fzf.zshThat enables the following keybindings.
| Key | Action |
|---|---|
Ctrl-R | Fuzzy-search command history |
Ctrl-T | Pick a file in the current directory and insert it on the command line |
Alt-C | Fuzzy cd into a subdirectory |
Switching fzf's file-search backend to fd makes it faster and also respects .gitignore.
export FZF_DEFAULT_COMMAND='fd --type f --hidden --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS="--height 40% --reverse --border"Example of a handy function alias:
# when rg +
rgf() {
rg --line-number --no-heading --color=always "${1:-}" |
fzf --ansi --preview 'bat --color=always {1} --highlight-line {2}'
}Example Workflows Combining the Tools
# 1) "deprecated" file , , check
rg -l deprecated | fzf --preview 'bat --color=always {}'
# 2) .log file
fd -e log /var/log | fzf | xargs tail -n 50
# 3)
rg "function " -n | fzfWrap-up
| Tool | Replaces | One-line summary |
|---|---|---|
rg | grep | Fast recursive search that understands .gitignore |
fd | find | Intuitive file search where you just write a pattern |
bat | cat | Viewer with syntax highlighting, line numbers, and Git markers |
fzf | — | Fuzzy finder that interactively narrows any list |
Each of these four tools is useful on its own, but they are most powerful when combined in a pipeline, as in rg | fzf --preview bat. You do not need to throw away the classic tools. Split the roles: use grep/find/cat when script compatibility and portability matter, and use the modern tools for everyday interactive exploration.
AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us
Questions & answers
Ask a question about this guide. We'll review and reply.