You could easily replace that with /etc for example: This is all very easy because Linux includes GNU grep. The dot simply means start the search from the current working directory. Scanning all C++ files under current directory awk -v wordsListFile=nameSpacesListFile.txt -f script.awk $(find. If you’re using Linux, performing a recursive grep is very easy. text-in-dep5-copyright debian/copyright GPL-2 debian/source/lintian. WordsListCount = split(wordsListStr, wordsListArr, "\n") # split wordsListStr by newLine into array wordsListArr, saved array length into wordsListCountįor (currWord in wordsListArr) wordsMatchArr = 0 # reset array wordsMatchArr to 0 grep usr/share/lintian/overrides/9base:83. Getline wordsListStr < wordsListFile # read wordsListFile as single string wordsListStr script.awk BEGIN # set record seperator to something unlikely matched, causing each file to be read entirely as a single record Print file name only if all words matched. We have learned how to use grep to find a string in the specified files. Scanning each file once for all the words (read each file as a single record). I suggest to use gawk (standard Linux awk) script. Files pass the filter if they contain at least one instance of each word. I have tried opening these files in vim and searching there using /pattern and it finds the pattern. The weird thing is that the output does not list occurrences in some files which definitely contain the string. The pattern is just a word, no regular expression. Surely there is a way to do this? This is essentially a filtering problem: Take all the files found (recursively) inside a directory, and apply a filter to them for each of the words in the input list. For this, I call grep recursively like so. Do this recursively to obtain all results in all files in a directory.Return the list of files found where ALL words in the list of search words are found in the same file. Here is what I want a grep-like tool to do: The actual name of the class I am searching for is "Parameter", which is such a generic word that it too appears in hundreds of files.In my case, the namespace "MYNAMESPACE" appears in hundreds of source files.Assume that although M圜lass and MYNAMESPACE appear to be likely to be unique strings, in general they might not be.Search for all files which contain matches for "M圜lass" in the namespace "MYNAMESPACE".I am working with some C++ source code, and I want to be able to grep for objects in my code to find the files containing the relevant information. This is a frequent problem when working with source code, so I am pretty sure there must be an adequete solution. However I am hoping that if this is the case there might be some other Linux/Unix command line tool which will do the job I want. I am fairly confident this can't be done with grep, unless there are some features that I don't know about.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |