Search files first, then edit in place.

Section: Practical Recipes

Replace text across many files safely

bash
bash
rg -l 'old-service-name' . | xargs sed -i 's/old-service-name/new-service-name/g'
Explanation

A practical codebase refactor pattern when you understand the scope of the match set.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Practical Recipes
Show most frequent error messages
Count and rank repeated lines in a log.
OpenIn sheetbashsame section
Show effective config lines only
Remove comments and blank lines from a config file.
OpenIn sheetbashsame section
Sum a CSV column
Compute the total of a numeric CSV field after skipping the header.
OpenIn sheetbashsame section
Find the largest files in a tree
List the top 20 largest files by size.
OpenIn sheetbashsame section
Extract unique IP addresses
Print unique IPs from a log file.
OpenIn sheetbashsame section
Pass stdin items as arguments
Convert lines into command arguments.
OpenIn sheetbash1 tag match