2014-07-28

Better Grep, Grep files with line numbers (ag)

Sometimes when programming on my old Netbook (that not powerful enough top open any IDE, so I must use just a standard text editor such as Vim or GEdit), I need to quickly search some string (function, symbol or signature) on all source code in my project, that I will use:

grep -n Symbol *.rb */*.rb */*/*.rb

(-n is line number, Symbol is the search string) that will show something like this:


Now I found a better way, The Silver Searcher! Ag (argentum, latin name for Silver), when using Ubuntu, you could install it using this command:

sudo apt-get install silversearcher-ag

or when using ArchLinux:

sudo pacman -Sy the_silver_searcher

and use it just like grep ^_^)b for example:

ag --ruby Symbol .

(--ruby means all ruby source code, dot means only on current directory, recursively) that will show something like this: 





No comments :

Post a Comment

THINK: is it True? is it Helpful? is it Inspiring? is it Necessary? is it Kind?