This script is similar to:
ag pattern -l | xargs sed -i 's;pattern;replace;g'
with the added benefit that you can use proper regular expressions (e.g. grouping, lookaheads etc which are not supported on sed...).
Since ag
is being used for searching the files, performance shouldn't be too bad (especially on SSDs).