Using sed for find-replace

In the I-can’t-believe-I-didn’t-know-yet category, here’s a command-line find-replace:

sed -i 's/findthis/replacewith/g' thefile.txt

Or recursive, for all files under the current directory:

find ./ -type f -exec sed -i 's/findthis/replacewith/g' {} \;

From brunolinux.com.

1 Comment

  1. Guess you didn't get a lot of jokes I made then... =)

Leave your thoughts
  • You can use some HTML in your comment.
  • Your comment may not display immediately due to spam filtering. Please wait for moderation.