0

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 ?

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175

3 Answers3

1

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.

Inian
  • 12,472
  • 1
  • 35
  • 52
0

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.

Lars Fischer
  • 101
  • 2
-1

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.