Find and Replace in multiple files

As a software programmer you often have to search and replace a specific string in multiple files because of a refactoring or just improving a variable or function name. Normally you can use your IDE or your editor for this. But in bigger codebases with thousand or million lines of code it can be very slow. Neither do IDEs work with remote SSH-sessions. In such situations the command-line is pretty handy....

April 13, 2019 · 1 min · Daniel Gerlach

ag the_silver_searcher, a grep replacement

As a programmer you often search for a specific strings or regexps in multiple files. Previously i used to do this with the well-known GNU-tools find and grep. The following command searches for main in all *.go files in the current directory and: 1 2 find . -iname '*.go' | xargs grep -inH "main" # -i ignore case, -n print line number, -H print filename Recently i discovered ag the silver searcher....

April 13, 2019 · 1 min · Daniel Gerlach