Skip to main content
Tweeted twitter.com/StackUnix/status/1181811672849276928
Notice removed Needs detailed answers by terdon
Notice added Needs detailed answers by terdon
file here is used pretty much differently as how it's used elsewhere "Manipulating files: copying, renaming, searching, analyzing, archiving, etc."
Link
Braiam
  • 36.9k
  • 29
  • 114
  • 176
Question Protected by CommunityBot
added 114 characters in body
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

Replacing strings in files based on certain search criteria is a very common task. How can I

  • replace string foo with bar in all files in the current directory?
  • do the same recursively for sub directories?
  • replace only if the file name matches another string?
  • replace only if the string is found in a certain context?
  • replace if the string is on a certain line number?
  • replace multiple strings with the same replacement
  • replace multiple strings with different replacements

Replacing strings in files based on certain search criteria is a very common task. How can I

  • replace string foo with bar in all files in the current directory?
  • do the same recursively for sub directories?
  • replace only if the file name matches another string?
  • replace only if the string is found in a certain context?
  • replace if the string is on a certain line number?

Replacing strings in files based on certain search criteria is a very common task. How can I

  • replace string foo with bar in all files in the current directory?
  • do the same recursively for sub directories?
  • replace only if the file name matches another string?
  • replace only if the string is found in a certain context?
  • replace if the string is on a certain line number?
  • replace multiple strings with the same replacement
  • replace multiple strings with different replacements
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

How can I replace a string in a file(s)?

Replacing strings in files based on certain search criteria is a very common task. How can I

  • replace string foo with bar in all files in the current directory?
  • do the same recursively for sub directories?
  • replace only if the file name matches another string?
  • replace only if the string is found in a certain context?
  • replace if the string is on a certain line number?