Hacker News new | ask | show | jobs
by noste 4892 days ago
How about using diff and sed -i?

  # This version is obviously unsafe
  verbose_sed() {
    sed -i.old -e "$1" "$2"
    diff -u "$2.old" "$2"
    rm "$2.old"
  }
  
  verbose_sed s/vim/emacs/g rant.txt
You could then use all the tools that we already have for working with patches: colordiff to colorize the output, diffstat for a summary of changes, patch -R for reverting the changes, and so on.

Of course, you're more likely to than not already using version control, which gives you all this and much more, even if you were to use vanilla find+sed.