—
tags: ‘shell, linux, command, development, grep,find’
categories: development
—
I use the following command to find a string in a Go repo. The vendor directory is not needed, so skip it.
$ find . -type f |grep -v vendor|cut -d":" -f2|xargs grep -n my_search_string
The command find all files in current directory. Next, it removes all files that have vendor in their path.
401:./.git/HEAD
402:./.git/info/exclude
403:./.git/logs/HEAD
The cut
command picks the filename and passed to xargs
. Each file is then processed by grep
for the search string.