For x86 binaries: go get github.com/piranha/goreplace go install github.com/piranha/goreplace is another way to get it if you have GO and GOPATH set up. I personally aliased it to 'gor' in my zshrc as the git plugin already occupied the 'gr' (short for git remote).
Go Replace - simple and fast search and replace tool for command line
11–20 of 64 posts
Re: Go Replace - simple and fast search and replace tool for command line
#12I really like Facebook's codemod.py for stuff like that: https://github.com/facebook/codemod It has something like automatic and manual modes, so you can check (and fix) every diff during the replacement
Re: Go Replace - simple and fast search and replace tool for command line
#13 find ~/my/docs/ -type f -name '*.txt' -exec sed -i.bak 's/inheritance/composition/g' {} +
This will search all files ending in `.txt` and will exec `sed 's/inheritance/composition/g'` on it. Sed modifies files in-place and saves a backup file with .bak extension (-i.bak) and is called the minimum necessary times (-exec +).My best advice to someone using the command line is to learn `find` + `xargs` or, even better, `find` + `parallel`.
Re: Go Replace - simple and fast search and replace tool for command line
#14find ~/my/docs/ -type f -name '*.txt' -exec sed -i.bak 's/inheritance/composition/g' {} + This will search all files ending in `.txt` and will exec `sed 's/inheritance/composition/g'` on it. Sed modifies files in-place and saves a backup file with .bak extension (-i.bak) and is called the minimum necessary times (-exec +). My best advice to someone using the command line is to learn `find` + `xargs` or, even better,…
Re: Go Replace - simple and fast search and replace tool for command line
#15Wow, it's super fast AND the output looks great. Good job, piranha! Copied to /usr/bin, I will use this a lot.
Re: Go Replace - simple and fast search and replace tool for command line
#16Note that specifically for Go source code, there is "go fix -r" for syntax/context-aware code replacement (see "godoc fix").
Re: Go Replace - simple and fast search and replace tool for command line
#17Nice! svn support would be useful (ignore .svn directories) and the -r option is easy to remember, but perhaps not so much in line with the already messy standard Unix options (-r or -R for recursive operation). Note that specifically for Go source code, there is "go fix -r" for syntax/context-aware code replacement (see "godoc fix").
To be honest, I was just lazy inventing a command line key and it's recursive by design, so it happened this way. Plus, as you say, it's easy to remember because of mnemonics.
I haven't touched svn repos in years, but yeah, that could be added. I know they exist, it just that I haven't felt the need to support them.
Re: Go Replace - simple and fast search and replace tool for command line
#18I really like Facebook's codemod.py for stuff like that: https://github.com/facebook/codemod It has something like automatic and manual modes, so you can check (and fix) every diff during the replacement
Its a little bit different from Go Replace, giving the option to drop on your editor if the current replacement can't be appied directly (this is the great feature).
Re: Go Replace - simple and fast search and replace tool for command line
#19 C:\Users\swah\docs>gr TEST
panic: Given path should be anchored at /
goroutine 1 [running]:
main.NewIgnorer(0xc08005bcf0, 0x29, 0x0, 0x0, 0x140110, ...)
/Users/piranha/dev/go/src/goreplace/ignore.go:32 +0xa4
main.main()
/Users/piranha/dev/go/src/goreplace/goreplace.go:62 +0x1b7
goroutine 2 [runnable]:
[edit] New version is working!