Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

searching a file

Debasis Mishra
Occasional Advisor

searching a file

suppose in my unix login 10 folders is present. i have a abc.h header file. i forget where this header file is present. so which command i will use in unix, so that it will search from all folders.
8 REPLIES
Sergejs Svitnevs
Honored Contributor

Re: searching a file

please execute:
# find / -name abc.h

Regards
Paul Cross_1
Respected Contributor

Re: searching a file

Depending on the size of your filesystem, this command could take a long long time.
Ivan Ferreira
Honored Contributor

Re: searching a file

If you know that the file is in one directory below your current directoy, just use:

find . -name abc.h

To limit the search a little more. This will search in your current directory and all subdirectories.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Vitaly Karasik_1
Honored Contributor

Re: searching a file

locate abc.h

will provide you with all locations of abc.h file immediately, because "locate" doesn't search filesystem, but just in it's indexed database. In most distros this database is updated once a day via cron job, which runs "updatedb" utility.
Steve_160
Frequent Advisor

Re: searching a file

"Locate" is the best way to find something, but if the files were recently created it won't know about them until the database is updated. In my system (Fedora Core 3) this happens once daily by default.

If you do have to resort to "find," use "find / -mount (filename)" to keep it from searching mounted file servers.
#@%!! Windows!
Paul Cross_1
Respected Contributor

Re: searching a file

Locate assumes that you are indexing the contents of your filesystem. I don't do this on production systems, because you take an I/O hit during the indexing process.
Fine for workstations though.
Muthukumar_5
Honored Contributor

Re: searching a file

Use find or locate.

find -type f -name "abc.h"

will give that. (or)

locate abc.h

--
Muthu
Easy to suggest when don't know about the problem!
Sivakumar TS
Honored Contributor

Re: searching a file

Hi,

#find / -name abc.h -print

hope this helps.

Regards,

Siva.
Nothing is Impossible !