14 September 2014

Find And Replace From Outside Of Files

Toss this puppy in your .bashrc for string substitution from outside of files.

function ack_sub {
  ack -l $1 $3 | xargs perl -pi -E 's/'$1'/'$2'/g'
}

Syntax

ack_sub <target> <substitution> <directory>

Example

$ ack_sub "Mikey" "Michael" "./taxes"