Tags: #shell
gsed -i 's/metrics.NewWriter(/metrics.NewLegacyWriter(/' **/*.go
# UPDATE: glob/wildcard doesn't appear to work any more, needs to be individual file streams
find . -type f -name *.go -exec gsed -i 's/foo/bar/' {} \;
# You'll need both -e (extended regex support) and -r (allow backreferences like \1 \2 etc) for more complex examples:
find . -type f -name *.go -exec gsed -i -r -e 's/, ErrMissing(.+)/, NewFieldError("\1")/' {} \;
find . -type f -name *.go -exec gsed -i -r -e 's/(github.com\/)fastly(\/customcli\/)/\1integralist\2/' {} \;
:argdo %s/metrics.NewWriter(/metrics.NewLegacyWriter(/ge | update
# If I'm working with a file type (like go) that messes with the quickfix window I'll typically pipe the list of files into Vim with no vimrc set.
vim $(search "--files=*.go" "metrics\.NewWriter" ./ | cut -d ':' -f 1)