Skip to content

Ersin Akyüz

  • Home
  • About
  • LinkedIn
  • GitHub

Replace a String in Multiple Files in Linux Using Grep and Sed

August 12, 2015 by Ersin Akyüz
Example
grep -rl 'old-string' ./ | xargs sed -i 's/old-string/new-string/g'

This will search for the string ‘old-string’ in all files relative to the current directory and replace ‘old-string’ with ‘new-string’ for each occurrence of the string in each file.

Categories linux
How to connect Oracle DB with PowerShell
raspberry pi released 5$ model raspberry pi zero!
© 2026 Ersin Akyüz • Built with GeneratePress