Search and automation for OBTF: grep, rg, fzf, and scripts
A large text file is not a problem if you can search it quickly. The command line gives you precise search, context around matches, and room to automate routine work. Below are practical commands for grep, ripgrep, and fzf, plus a few safe scripts.
Basic search
ripgrep is usually faster and more convenient than grep. It searches files, shows line numbers, and supports regular expressions.
rg -n "TODO" everything.txt
rg -n -C 3 "project X" everything.txt
rg -ni "idea|thought" everything.txt
rg -n "2026-10" everything.txt
rg -n "^2026-10-29" everything.txt
-nshows line numbers.-C 3adds three lines of context before and after a match.-iignores case.^2026-10-29finds a line that starts with the date.
If rg is not installed, use grep -n. Add -r to search a directory.
grep -n "TODO" everything.txt
grep -rn "project X" ~/notes/
Context and filters
A single word often returns too many matches. Combine conditions and limit the search area.
rg -n "TODO.*\[work\]" everything.txt
rg -n -A 5 "TODO" everything.txt
rg -n -B 2 "DONE" everything.txt
rg -n -g "*.txt" "idea" ~/notes/
rg -n --no-heading "project X" everything.txt
-A shows lines after a match, -B before it, and -g sets a file pattern. --no-heading removes file headers when you work with one file.
By default, rg respects .gitignore. If a file is excluded, add -u to search without those rules.
Interactive search with fzf
fzf turns a list of matches into an interactive picker. It helps when you remember the rough text but not the exact wording.
rg -n "TODO|Idea" everything.txt | fzf
rg -n --no-heading "project" everything.txt | fzf --preview 'echo {}'
You can open the selected line in an editor with a small script that parses the line number and calls the editor. If that feels excessive, use fzf only to pick the line and then find it again with rg.
Daily commands
A few commands cover most routine work.
# Open the file in your editor
$EDITOR everything.txt
# Find open tasks
rg -n "TODO:" everything.txt
# Find tasks for a project
rg -n "TODO.*\[work\]" everything.txt
# Look at entries for a specific day
rg -n "^2026-10-29" everything.txt
# Count lines and check size
wc -l everything.txt
du -h everything.txt
Save useful commands as aliases. For example, alias todo='rg -n "TODO:" ~/everything.txt' saves time if you check tasks several times a day.
Useful scripts
Automation does not have to be complex. Start with a copy, a backup, and a simple report.
# A dated backup
mkdir -p ~/backup
cp everything.txt ~/backup/everything-$(date +%F).txt
# Projects by mention count
rg -o "\[[^]]+\]" everything.txt | sort | uniq -c | sort -rn
# Number of open tasks
rg -c "TODO:" everything.txt
# Completed tasks for a month
rg -n "^2026-10-.*DONE:" everything.txt
You can schedule the backup script with cron or launchd. Keep the copy separate from the main file and make sure it is not overwritten by every mistake.
Safety for bulk edits
Search is safe. A bulk replace can damage the file. Before sed, awk, or a Python script, make a copy and test the command on that copy.
cp everything.txt everything.txt.bak
rg -n "old text" everything.txt
# Test the replacement on a copy first
sed 's/old text/new text/g' everything.txt.bak > /tmp/check.txt
diff -u everything.txt.bak /tmp/check.txt | head -60
If the file is in Git, commit it before the change. Then a mistake can be undone with one command. Do not store passwords or keys in the file, even if it stays local.
Platforms
On macOS, install the tools with Homebrew: brew install ripgrep fzf. On Debian or Ubuntu: apt install ripgrep fzf. On Windows, WSL is the easiest path to the same commands. PowerShell has Select-String, but the syntax is different.
When moving commands between macOS and Linux, check sed. GNU and BSD versions use different flags for in-place replacement.
When a graphical interface is needed
The command line works well on a computer, but it does not replace mobile access or collaboration. For a phone, use an editor connected to a synced folder. For a team, use a tool with shared access. See the guides on sync and text editors.
Checklist
rgorgrepis installed and available in the terminal.- Searching dates, tasks, and projects takes seconds.
- Frequent searches have aliases or short commands.
- The backup is stored separately from the main file.
- A copy or Git commit exists before a bulk replacement.
- Commands work on your platform without flag changes.
If your task list grows, read how to keep tasks and projects in one file. If you want to ask questions across the archive, move on to RAG over a personal text file.
Start with a ready-made file. The template already has a date, markers, and example entries.