Is there a "find file on system" command?
The subject says it all. There was even a 3rd-party command in DOS (whereis) which would search the system for a file name, regardless of its directory. I have never been able to find such a program on Linux.
Doug McGarrett wrote:
The subject says it all. There was even a 3rd-party command in DOS (whereis) which would search the system for a file name, regardless of its directory. I have never been able to find such a program on Linux.
"locate" is really useful and quick. I think it's in the findutils package. You'll need to run "updatedb" to use it. You can also use "find" as in "find <directory> "*file" -- Jim Sabatke Hire Me!! - See my resume at http://my.execpc.com/~jsabatke Do not meddle in the affairs of Dragons, for you are crunchy and good with ketchup.
On Saturday 15 May 2004 02.51, Doug McGarrett wrote:
The subject says it all. There was even a 3rd-party command in DOS (whereis) which would search the system for a file name, regardless of its directory. I have never been able to FIND such a program on Linux.
(Captions added)
On Sat, May 15, 2004 at 03:00:50AM +0200 or thereabouts, Anders Johansson wrote:
On Saturday 15 May 2004 02.55, Anders Johansson wrote:
(Captions added)
Captions? I meant "capitals", really I did
hey, any guy who can spell meshuggene is okay by me LOL... -- Gary
Anders Johansson wrote:
On Saturday 15 May 2004 02.55, Anders Johansson wrote:
(Captions added)
Captions? I meant "capitals", really I did
Oh... I thought you were adding something like "Closed captioned for the humour impaired". ;-)
The subject says it all. There was even a 3rd-party command in DOS (whereis) which would search the system for a file name, regardless of its
----- Original Message -----
From: "Doug McGarrett"
I have never been able to find such a program on Linux.
I always: su find directory -name filename hence to search the entire computer for all rpm's find / -name *.rpm Need to be root Rob
On Friday 14 May 2004 03:06 pm, Rob Freeman wrote:
I have never been able to find such a program on Linux.
I always:
su find directory -name filename
hence to search the entire computer for all rpm's
find / -name *.rpm
Need to be root
Rob
su Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
Jerome Lyles wrote:
On Friday 14 May 2004 03:06 pm, Rob Freeman wrote:
I have never been able to find such a program on Linux.
I always:
su find directory -name filename
hence to search the entire computer for all rpm's
find / -name *.rpm
Need to be root
Rob
su
Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
That command works fine here. Maybe you typed it wrong. ;-)
On Monday 17 May 2004 12:51 am, James Knott wrote:
Jerome Lyles wrote:
On Friday 14 May 2004 03:06 pm, Rob Freeman wrote:
find / -name *.rpm
Need to be root
Rob
su
Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
That command works fine here.
Maybe you typed it wrong. ;-)
For me: find / -name *.rpm doesn't work but: find / -name '*.rpm' does. Do you know why? Jerome
On Mon, 2004-05-17 at 04:43, Jerome Lyles wrote:
On Friday 14 May 2004 03:06 pm, Rob Freeman wrote:
I have never been able to find such a program on Linux.
I always:
su find directory -name filename
hence to search the entire computer for all rpm's
find / -name *.rpm
Need to be root
Rob
su Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
I have had this experience for some time with the find command. If I change to / it then works fine. May be time to contact the programmers about this bug. -- Ken Schneider unix user since 1989 linux user since 1994 SuSE user since 1998 (5.2)
On Monday 17 May 2004 03:43, Jerome Lyles wrote:
On Friday 14 May 2004 03:06 pm, Rob Freeman wrote:
I have never been able to find such a program on Linux.
I always:
su find directory -name filename
hence to search the entire computer for all rpm's
find / -name *.rpm
Need to be root
Rob
su
Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
You need to put quotes around the expression you are looking for if it contains special characters that the shell will act on (in your case the *). Try this... find / -name "*.rpm" You want the find command to see the *, not the shell. -- Robert C. Paulsen, Jr. robert@paulsenonline.net
Robert Paulsen wrote:
On Monday 17 May 2004 03:43, Jerome Lyles wrote:
On Friday 14 May 2004 03:06 pm, Rob Freeman wrote:
I have never been able to find such a program on Linux.
I always:
su find directory -name filename
hence to search the entire computer for all rpm's
find / -name *.rpm
Need to be root
Rob
su
Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
You need to put quotes around the expression you are looking for if it contains special characters that the shell will act on (in your case the *). Try this...
find / -name "*.rpm"
You want the find command to see the *, not the shell.
barrabas:/ftp/apr04/cdrtools-2.01 # time find /usr -name 3Ddiag* -print0 /usr/bin/3Ddiag.runtime/usr/bin/3Ddiag.nvidia_glx/usr/bin/3Ddiag-result/usr/bin/3Ddiag.devel/usr/bin/3Ddiag/usr/bin/3Ddiag.ignoredb/usr/bin/3Ddiag.dri real 2m44.757s user 0m0.680s sys 0m8.060s Time enough to make that cup of cofee. barrabas:/ftp/apr04/cdrtools-2.01 # time locate 3Ddiag /data1/SZB50/usr/bin/3Ddiag /data1/SZB50/usr/bin/3Ddiag-result /data1/SZB50/usr/bin/3Ddiag.devel /data1/SZB50/usr/bin/3Ddiag.dri /data1/SZB50/usr/bin/3Ddiag.ignoredb /data1/SZB50/usr/bin/3Ddiag.mesaglide /data1/SZB50/usr/bin/3Ddiag.mesasoft /data1/SZB50/usr/bin/3Ddiag.nvidia_glx /data1/SZB50/usr/bin/3Ddiag.runtime /data1/SZB50/usr/bin/3Ddiag.sh /data1/usr/bin/3Ddiag /data1/usr/bin/3Ddiag-result /data1/usr/bin/3Ddiag.devel /data1/usr/bin/3Ddiag.dri /data1/usr/bin/3Ddiag.ignoredb /data1/usr/bin/3Ddiag.nvidia_glx /data1/usr/bin/3Ddiag.runtime /data1/var/tmp/3ddiag-0.703-build/usr/bin/3Ddiag /data1/var/tmp/3ddiag-0.703-build/usr/bin/3Ddiag-result /data1/var/tmp/3ddiag-0.703-build/usr/bin/3Ddiag.devel /data1/var/tmp/3ddiag-0.703-build/usr/bin/3Ddiag.dri /data1/var/tmp/3ddiag-0.703-build/usr/bin/3Ddiag.ignoredb /data1/var/tmp/3ddiag-0.703-build/usr/bin/3Ddiag.nvidia_glx /data1/var/tmp/3ddiag-0.703-build/usr/bin/3Ddiag.runtime /usr/bin/3Ddiag /usr/bin/3Ddiag-result /usr/bin/3Ddiag.devel /usr/bin/3Ddiag.dri /usr/bin/3Ddiag.ignoredb /usr/bin/3Ddiag.nvidia_glx /usr/bin/3Ddiag.runtime real 0m2.311s user 0m1.460s sys 0m0.046s On a XP2800+ 512MB, that was. With "locate -i" it will ignore case. Regards Sid. -- Sid Boyce .... Hamradio G3VBV and keen Flyer Linux Only Shop.
Robert Paulsen wrote:
On Monday 17 May 2004 03:43, Jerome Lyles wrote:
Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
You need to put quotes around the expression you are looking for if it contains special characters that the shell will act on (in your case the *). Try this...
find / -name "*.rpm"
You want the find command to see the *, not the shell.
It works fine for me without the quotes. However, this is on Red Hat 7.3.
On Monday 17 May 2004 7:35 pm, James Knott wrote:
Robert Paulsen wrote:
On Monday 17 May 2004 03:43, Jerome Lyles wrote:
Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
You need to put quotes around the expression you are looking for if it contains special characters that the shell will act on (in your case the *). Try this...
find / -name "*.rpm"
You want the find command to see the *, not the shell.
It works fine for me without the quotes. However, this is on Red Hat 7.3.
Sometimes it will, and sometimes it won't. To understand why, you need to better understand how regexs are expanded under UNIX. To use the above example, let's say I type this: $ find / -name *.rpm Now, if there are no in the current directory that match the '*.rpm' pattern, the shell will try to expand this pattern, will find no matches, and thus find will get invoked with argv: argv[0] = "find", argv[1] = "/", argv[2] = "-name", argv[3] = "*.rpm". Now, let's assume that in the current directory, there are two rpm files: "file1.rpm" and "file2.rpm". Now, the *shell* will expand '*.rpm' to "file1.rpm" and "file2.rpm", and, thus, will invoke find with argv: argv[0] = "find", argv[1] = "/", argv[2] = "-name", argv[3] = "file1.rpm", argv[4] = "file2.rpm". Find will look at this, and say "huh?". It's only expecting a single argument to '-name', but now you've passed it two. It's even worse if there's only one match "file.rpm"; the shell will expand "*.rpm" to "file.rpm": argv[0] = "find", argv[1] = "/", argv[2] = "-name", argv[3] = "file.rpm". Now, find will see a single argument to "-name", as it expects, but the pattern being passed to it is "file.rpm" _not_ "*.rpm" as you expected. find will silently do exactly what you told it to do, but not what you expected. The moral of the story is that in UNIX, is the *shell* that does the expansion of command line arguments. Does this help? -Nick -- <<< Why, oh, why, didn't I take the blue pill? >>> /`-_ Nicholas R. LeRoy The Condor Project { }/ http://www.cs.wisc.edu/~nleroy http://www.cs.wisc.edu/condor \ / nleroy@cs.wisc.edu The University of Wisconsin |_*_| 608-265-5761 Department of Computer Sciences
On Monday 17 May 2004 19:35, James Knott wrote:
Robert Paulsen wrote:
On Monday 17 May 2004 03:43, Jerome Lyles wrote:
Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
You need to put quotes around the expression you are looking for if it contains special characters that the shell will act on (in your case the *). Try this...
find / -name "*.rpm"
You want the find command to see the *, not the shell.
It works fine for me without the quotes. However, this is on Red Hat 7.3.
If there are no *.rpm files in the current directory then it will work w/o the quotes. Try the following: touch xxx.rpm find . -name *.rpm find . -name "*.rpm" Assuming there are some rpm files to find in subdirectories you should see the difference. -- Robert C. Paulsen, Jr. robert@paulsenonline.net
Minor correction ... On Monday 17 May 2004 21:22, Robert Paulsen wrote:
On Monday 17 May 2004 19:35, James Knott wrote:
Robert Paulsen wrote:
On Monday 17 May 2004 03:43, Jerome Lyles wrote:
Password: # find / -name *.rpm find: paths must precede expression Usage: find [path...] [expression] #
What happened? Isn't '/' enough path for this command? Thanks, Jerome
You need to put quotes around the expression you are looking for if it contains special characters that the shell will act on (in your case the *). Try this...
find / -name "*.rpm"
You want the find command to see the *, not the shell.
It works fine for me without the quotes. However, this is on Red Hat 7.3.
If there are no *.rpm files in the current directory then it will work w/o the quotes. Try the following:
Should have said "in the directory where the find starts looking. That's / in the above and . in the following example.
touch xxx.rpm find . -name *.rpm find . -name "*.rpm"
Assuming there are some rpm files to find in subdirectories you should see the difference. -- Robert C. Paulsen, Jr. robert@paulsenonline.net
-- Robert C. Paulsen, Jr. robert@paulsenonline.net
Robert Paulsen wrote:
<snip >
touch xxx.rpm find . -name *.rpm find . -name "*.rpm"
Assuming there are some rpm files to find in subdirectories you should see the difference. -- Robert C. Paulsen, Jr. robert@paulsenonline.net
Don't forget about "locate." It's much faster for big searches. -- Jim Sabatke Hire Me!! - See my resume at http://my.execpc.com/~jsabatke Do not meddle in the affairs of Dragons, for you are crunchy and good with ketchup.
On Monday 17 May 2004 04:22 pm, Robert Paulsen wrote:
On Monday 17 May 2004 19:35, James Knott wrote:
Robert Paulsen wrote:
On Monday 17 May 2004 03:43, Jerome Lyles wrote:
You need to put quotes around the expression you are looking for if it contains special characters that the shell will act on (in your case the *). Try this...
find / -name "*.rpm"
You want the find command to see the *, not the shell.
It works fine for me without the quotes. However, this is on Red Hat 7.3.
If there are no *.rpm files in the current directory then it will work w/o the quotes. Try the following:
touch xxx.rpm find . -name *.rpm find . -name "*.rpm"
Assuming there are some rpm files to find in subdirectories you should see the difference. -- Robert C. Paulsen, Jr. robert@paulsenonline.net
I tried it and I do see the difference! So, if there are rpms in the current directory then the shell expands the special character *. If there are not rpms in the current directory then the shell does not expand the special characters for other directories. This is useful to know, thank you, Jerome
On Monday 17 May 2004 03:43, Jerome Lyles wrote:
You need to put quotes around the expression you are looking for if it contains special characters that the shell will act on (in your case the *). Try this...
find / -name "*.rpm"
You want the find command to see the *, not the shell.
I created a script file in /usr/local/bin/fnd
find . -depth -mount -name "$1" -print | less usage "fnd "*abc*"" will find all files in the subordinate paths matching the mask. Bob Stanfield 29 Ledge Ln Pipersville, PA 18947 V 610-294-9884 Fax 610-294-8119
On Friday 14 May 2004 08:51 pm, Doug McGarrett wrote:
The subject says it all. There was even a 3rd-party command in DOS (whereis) which would search the system for a file name, regardless of its directory. I have never been able to find such a program on Linux.
How about trying: 'whereis' :-) Good for most system files. +----------------------------------------------------------------------------+ + Bruce S. Marshall bmarsh@bmarsh.com Bellaire, MI 05/14/04 22:20 + +----------------------------------------------------------------------------+ "Bugs fly in through open Windows."
How about locate? findutils-locate-4.1.7-738.rpm -- "Contemplate the mangled bodies of your countrymen, and then say, 'What should be the reward of such sacrifices?' ... If ye love wealth better than liberty, the tranquility of servitude than the animating contest of freedom, go from us in peace. We ask not your counsels or arms. Crouch down and lick the hands which feed you. May your chains sit lightly upon you, and may posterity forget that ye were our countrymen!" --Samuel Adams http://federalist.com/news/islamicjoy.asp Mitch Thompson, San Antonio, Texas <quote who="Bruce Marshall">
On Friday 14 May 2004 08:51 pm, Doug McGarrett wrote:
The subject says it all. There was even a 3rd-party command in DOS (whereis) which would search the system for a file name, regardless of its directory. I have never been able to find such a program on Linux.
How about trying: 'whereis' :-)
Good for most system files.
+----------------------------------------------------------------------------+ + Bruce S. Marshall bmarsh@bmarsh.com Bellaire, MI 05/14/04 22:20 + +----------------------------------------------------------------------------+ "Bugs fly in through open Windows."
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Mitch Thompson wrote:
How about locate?
findutils-locate-4.1.7-738.rpm
I agree, it's fast compared to using the find command. It's about the most used command in Linux and the missing app that makes people curse when working with Solaris. Regards Sid. -- Sid Boyce .... Hamradio G3VBV and keen Flyer Linux Only Shop.
participants (14)
-
Anders Johansson
-
Bob Stanfield
-
Bruce Marshall
-
Doug McGarrett
-
Gary
-
James Knott
-
Jerome Lyles
-
Jim Sabatke
-
Kenneth Schneider
-
Mitch Thompson
-
Nick LeRoy
-
Rob Freeman
-
Robert Paulsen
-
Sid Boyce