1753440 Members
4625 Online
108794 Solutions
New Discussion юеВ

Re: 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 8
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 !