I need to search for all cpp / h files in the working copy of svn for "foo", excluding completely svn special folders. What is the exact command for GNU grep?
I use ack for this purpose, like grep, but it automatically knows how to exclude source control directories (among other useful things).
grep -ir --exclude-dir = .svn foo *
The working directory will work. Omit "i" if you want the search to be case sensitive.
If you want to check only .cpp and .h files, use
grep -ir --include = {. cpp,.h} --exclude-dir =.svn foo *
:
(.. ), ,
svn ls -R | xargs -d '\n' grep <string-to-search-for>
RTFM. "man grep" "/exclude" :
- = GLOB , GLOB ( ). glob *,? [...] \, .
- -= , FILE ( , --exclude).
- -Dir = DIR , DIR .
script, .bashrc. SVN- grep, .
bash grepping svn-... , ( vim ), IDE
vim
s () { local PATTERN=$1 local COLOR=$2 shift; shift; local MOREFLAGS=$* if ! test -n "$COLOR" ; then # is stdout connected to terminal? if test -t 1; then COLOR=always else COLOR=none fi fi find -L . \ -not \( -name .svn -a -prune \) \ -not \( -name templates_c -a -prune \) \ -not \( -name log -a -prune \) \ -not \( -name logs -a -prune \) \ -type f \ -not -name \*.swp \ -not -name \*.swo \ -not -name \*.obj \ -not -name \*.map \ -not -name access.log \ -not -name \*.gif \ -not -name \*.jpg \ -not -name \*.png \ -not -name \*.sql \ -not -name \*.js \ -exec grep -iIHn -E --color=${COLOR} ${MOREFLAGS} -e "${PATTERN}" \{\} \; } # s foo | less sl () { local PATTERN=$* s "$PATTERN" always | less } # like s but only lists the files that match smatch () { local PATTERN=$1 s $PATTERN always -l } # recursive search (filenames) - find file f () { find -L . -not \( -name .svn -a -prune \) \( -type f -or -type d \) -name "$1" }
Source: https://habr.com/ru/post/1698340/More articles:What causes the reappointment of this integer pointer? - cJava library for reading Microsoft Media Server Stream (MMS) - javarecursion instead of multi-loops - javaWhy is the width and height of the loaded SWFLoader equal to zero? - flexReplacing spaces with regex in PHP - phpHow to get Srcsrv with SVNindex.cmd for indexing extern files? - debuggingHow to interact with embedded PDFs in iframes via JavaScript? - javascriptA way to find out if an application is ASP.NET 1.1 or ASP.NET 2.0 - asp.netTest order automation - language-agnosticAn expanded web part does not appear in the Web Part Gallery: New Web Parts - c #All Articles