How can search for a file in ubuntu os with grep command ?
Let's say, I want to find CMakeList.txt, how to write grep command to find the existence of this file ?
How can search for a file in ubuntu os with grep command ?
Let's say, I want to find CMakeList.txt, how to write grep command to find the existence of this file ?
grep is not the right tool meant for this, use find with -name to specify the file name you want to get,
find . -type f -name "CMakeList.txt" -print
The above command searches for the file recursively from the current folder and all the sub-directories below.
If this is on a standard Linux installation, you might also try
locate CMakeFile.txt
If it is correctly installed, locate uses a cached index and is often much faster than a find from root directory.
Go into root directory, or a folder that you know your file is in, then
dir "CMakeFile.txt"
Will find it and its location. Works for me, at least.