Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Find Path to Files containing specific word – How can I know which file in a directory contain the specific word that I want?

I manage to find the word that I desire with the following command in a github repository

git log --all -p | grep 'abc'

abc is a word located in a specific file.

My question is how can I find the file path to the string that I desire? How can I know which file contain the word that I want which is abc ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

For example, doing the above command would get me

(this.b(),this.abc);

but I would like to know which exact folder and which exact file is this piece of string/code coming from.

Any suggestion is appreciated.

>Solution :

Just run

git log --all -p

This shows the output in the pager, usually less. You can search, scroll forward and backward.

To search the string, type / a b c Enter (the abc here is a regular expression, not a literal string). Type n to find the next occurrence. When you have found one, you can scroll back with b and look at the patch text to see which file it is. (BTW, type Space to scroll forward; type q to exit the pager.)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading