Interview Prep/Shell Scripting/Text processing: grep, sed, awk, cut, sort, uniq

How do you replace text across many files safely?

IntermediateConceptText processing: grep, sed, awk, cut, sort, uniq
Answer
grep -rlZ --include='*.yaml' 'registry.old.io' k8s/ |
  xargs -0 sed -i 's|registry\.old\.io|registry.new.io|g'
git diff --stat           # review before committing

grep -l lists only files that need changes, so unrelated files keep their mtime. -Z/-0 handle odd filenames. Escape . in the pattern (it means "any character" in regex). Run it in a Git working tree so you can review and revert.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Text processing: grep, sed, awk, cut, sort, uniq