PDA

View Full Version : How to search my FIlesystem by filename



maxplanck735
20th December 2006, 03:48 PM
How can I search my Filesystem by filename? For example, I want to search for all files on the filesystem whose filename contains the text "qt". I tried using the "Places->Search", but it only searches my Desktop.

I tried going into Search Preferences-> Indexing and adding all of the toplevel folders from the filesystem (it won't let me simply add the filesystem), but after doing this the search function still won't search these folders.

Thanks, any help is much appreciated.

timdsmith
20th December 2006, 03:50 PM
cd to the directory you want to start in....
Then
find . -name *qt*

maxplanck735
20th December 2006, 03:53 PM
Is there any way to do this from the GUI? (I'm talking about doing it from Gnome, without having to go to the command line.)

Thanks for the reply.

I ran "sudo updatedb" at the command line and now the "Search" feature turns up files located in the filesystem, however it seems to only search the text contained inside of the files, and NOT the filenames...

saqer
20th December 2006, 03:55 PM
Menu->find Files/Folders

maxplanck735
20th December 2006, 03:57 PM
Where is "Menu" located?

wneumann
20th December 2006, 04:01 PM
timdsmith's solution should have been "find . -name \*qt\*".

Running updatedb updates the locate database, after which "locate qt" finds files with qt in their name anywhere in your file system.

If you learn a little bit about the command line you'll find it hugely faster for most tasks.

maxplanck735
20th December 2006, 04:03 PM
i know the command line is faster, but it will then take me a lot more time to sort through all the files containing "qt" from the command line than it would take me from the GUI.

Can anyone tell me how to search for files with names containing a given text string from the GUI?

Thanks for all the replies so far.

mwette
20th December 2006, 04:03 PM
If you want to find files that contain "qt" then use something like


$ find . -type f -exec grep qt {} \; -print
or
$ find . -name '*.c' -exec grep qt {} \; -print


[EDIT: oops, I misread the request. I read the request as wanting to find files that contain the text "qt"]

maxplanck735
20th December 2006, 04:07 PM
Thanks for that info.

Does anyone know how to search for files containing a given text string from the GUI? (I'm talking about from the graphical interface, not from the command line.)

timdsmith
20th December 2006, 04:12 PM
timdsmith's solution should have been "find . -name \*qt\*".

Running updatedb updates the locate database, after which "locate qt" finds files with qt in their name anywhere in your file system.

If you learn a little bit about the command line you'll find it hugely faster for most tasks.Hmmm...I dunno...the command I typed seems to work fairly well...
~$ find . -name *qt*
./.qt
./.qt/.qt_plugins_3.3rc.lock
./.qt/qtrc
./.qt/.qtrc.lock
./.qt/qt_plugins_3.3rcYields the exact same results as find . -name \*qt\*

maxplanck735
20th December 2006, 04:21 PM
Does anyone know how to search for files containing a given text string from the GUI? (I'm talking about from the graphical interface, not from the command line.)

timdsmith
20th December 2006, 04:22 PM
Thanks for that info.

Does anyone know how to search for files containing a given text string from the GUI? (I'm talking about from the graphical interface, not from the command line.)Places > Computer > Filesystem....Click Go >> Search. That will give you a search bar.

maxplanck735
20th December 2006, 04:25 PM
I went to Places > Computer > Filesystem, but I don't see "Go" anywhere... I tried looking in the menu bar of the window, and right clicking on "Filesystem," still no luck...

timdsmith
20th December 2006, 04:29 PM
Sorry...I changed my default behavior because it drives me nuts for it to open a new window for every folder I click on...By default, the search feature is under the "Places" menu when you get to filesystem. Then you have to change the location you want to search from.

mwette
20th December 2006, 05:21 PM
Hmmm...I dunno...the command I typed seems to work fairly well...
~$ find . -name *qt*
./.qt
./.qt/.qt_plugins_3.3rc.lock
./.qt/qtrc
./.qt/.qtrc.lock
./.qt/qt_plugins_3.3rcYields the exact same results as find . -name \*qt\*

There is a risk with not quoting wildcards like '*' and '?'. If your current directory
contains a file that matches *qt* then you will not get the behavior you expect.
Try to add a file "xqty" and then run your find command. I don't think it will work.
But if you escape or single-quote the expression ('*qt*' or \*qt\*) it will always work.

maxplanck735
20th December 2006, 05:30 PM
Sorry...I changed my default behavior because it drives me nuts for it to open a new window for every folder I click on...By default, the search feature is under the "Places" menu when you get to filesystem. Then you have to change the location you want to search from.

This seems to be searching for files that CONTAIN THE TEXT "qt". I'm trying to find files that have the text "qt" in their filename.

Anyone know how to do it?

jesus h. christ do i hate linux... too bad the killer app that I absolutely must run supposedly only works on linux.

timdsmith
20th December 2006, 05:53 PM
*sigh* If you just put qt in the search field, with no quotes...no asterisks...nothing around it, just qt...then it will search for file names that contain qt.

RupertPupkin
20th December 2006, 05:57 PM
*sigh* If you just put qt in the search field, with no quotes...no asterisks...nothing around it, just qt...then it will search for file names that contain qt.
The funny thing is if he had just used the command-line in the 2 hours since he first posted, he could have saved the output to a text file and then opened that text file to find what he was looking for. :)

timdsmith
20th December 2006, 06:14 PM
hahaha!!! Yeah. I know.
Is it just me or does he seem totally unwilling to poke around for the feature. I never use the gui for searches, but it only took me about 15 seconds to dig around and find the search feature...I repeat...
*sigh*

maxplanck735
20th December 2006, 06:21 PM
I did use the command line and it worked. But I want to be able to use the GUI in the future, b/c it's easier to manage and sort the results.


*sigh* If you just put qt in the search field, with no quotes...no asterisks...nothing around it, just qt...then it will search for file names that contain qt.

I did this, and it just keeps searching forever and finds nothing. Since it keeps searching forever (at least for the past few hours), I'm assuming that it's searching the text contained within all files on the file system, rather than just the file names.

Does anyone know what's going on with this?

wneumann
20th December 2006, 06:51 PM
To timdsmith

Your command "find . -name *qt*" expands the wildcard before executing find, so it only finds files in the current directory and not in subdirectories. If that is what you want to do, "ls *qt*" is faster and easier. To search also in subdirectories you need "find . -name \*qt\*" so that the wildcard is not expanded before "find" gets to see it.

You happened to have a directory with "qt" in its title in your current directory, so you were lucky

mwette
20th December 2006, 07:18 PM
To timdsmith

Your command "find . -name *qt*" expands the wildcard before executing find, so it only finds files in the current directory and not in subdirectories. If that is what you want to do, "ls *qt*" is faster and easier. To search also in subdirectories you need "find . -name \*qt\*" so that the wildcard is not expanded before "find" gets to see it.

You happened to have a directory with "qt" in its title in your current directory, so you were lucky

Actually, it seems the default behavior of bash now is that if there is no file containing qt
then the wildcards characters are passed to the program (find). For example,


$ echo *qt*
*qt*
$ touch xqty
$ echo *qt*
xqty


See the bash man page, specifically the section titled
"pathname expansion" for more complete explanation. Not quoting wildcards
creates risk. It bugs me to see people ignore this issue.

bryancole
20th December 2006, 08:46 PM
The GUI front-end to the find command is called "gnome-search-tool". It should still be installed as part of gnome, but apparently, it's menu-entry has been removed, since the introduction of beagle-search. You can start it from the command line, though.

timdsmith
20th December 2006, 08:47 PM
See! Learn something every day! :D

bryancole
20th December 2006, 09:04 PM
You can re-enable the "Search For File..." menu option (which lauches the traditional gnome-search-tool) by editing the file /usr/share/applications/gnome-search-tool.desktop. You need to change the "catagories" line to:

Categories=GNOME;GTK;Application;System;Core;

This tells gnome to display this item in the System Tools menu. After this change, the item will still not yet be visible in the menus, but you can now find it in the menu-editor and re-enable it there.

HTH

maxplanck735
21st December 2006, 12:46 AM
You can re-enable the "Search For File..." menu option (which lauches the traditional gnome-search-tool) by editing the file /usr/share/applications/gnome-search-tool.desktop. You need to change the "catagories" line to:

Categories=GNOME;GTK;Application;System;Core;

This tells gnome to display this item in the System Tools menu. After this change, the item will still not yet be visible in the menus, but you can now find it in the menu-editor and re-enable it there.

HTH

There is no such file, "gnome-search-tool.desktop." in the directory /usr/share/applications/

I looked in the Add/Remove Software option, but I can't find anything matching "gnome search."

I would search my hard drive for the file, but that's what we're trying to make work here, hahaha....and all of this command line searching bullshlt is so complicated that half the people posting about it don't even understand how to use it... and apparently the syntax changes all the time, wotta fukking joke linux is. i'm so confused at this point that I have no idea how to search the filesystem from the command line.

At least linux isn't governed by some corporate idiots, rather it's governed by a bunch of people who don't have the resources to make it work as it should. Aren't humans a grand species...

jeez, this is fukking ridiculous, you'd think they'd leave such a basic feature in the GUI instead of replacing it with a tool which is not capable of doing what its predecessor was able to do.

bob
21st December 2006, 02:43 AM
Max, we have kids in this Forum and your phonetic misspellings are not appropriate. Hopefully you can express your opinions without them.

u-noneinc-s
21st December 2006, 04:11 AM
Just type gnome-search-tool on that "dirty word" command line and gnome-search-tool will open. Even using a GUI you are going to come up with and have to search the same list as you get on the command line.
And with CLI, you can refine your search with grep like locate qt |grep conf which will return any filenames containing BOTH qt and conf (for example) locate qt |grep milk will find your file 1qt_of_milk (if you had such a file name)

bryancole
21st December 2006, 09:25 AM
N.B. gnome-search-tool is part of the "gnome-utils" package. In case this isn't installed, run (as root) "yum install gnome-utils".

BTW. It seems the original poster wants to find files relating to the Qt package (I assume). Rather than search your entire hard-disk for things with Qt in the name, you can list the contents of the qt pacakge directly (and thus get more relevent results). Try (at the command line ... it really is better...)

rpm -ql qt qt-devel

You can filter the output with grep, to narrow your search (as others have discussed above). There are many more rpm query options to list and format the output but you'll need to read the man page for these (as I can't remember the details; I just do rpm -ql <package> | grep ... most the time).

wneumann
24th December 2006, 02:46 AM
Mwette wrote: "Actually, it seems the default behavior of bash now is that if there is no file containing qt then the wildcards characters are passed to the program (find). See the bash man page, specifically the section titled "pathname expansion" for more complete explanation. Not quoting wildcards creates risk. It bugs me to see people ignore this issue."

Thanks for pointing this out. I use tcsh, not bash, and now I'm glad -- bash seems to have some real idiot on the development team. That is a pretty dangerous feature.

mwette
24th December 2006, 02:51 AM
Mwette wrote: "Actually, it seems the default behavior of bash now is that if there is no file containing qt then the wildcards characters are passed to the program (find). See the bash man page, specifically the section titled "pathname expansion" for more complete explanation. Not quoting wildcards creates risk. It bugs me to see people ignore this issue."

Thanks for pointing this out. I use tcsh, not bash, and now I'm glad -- bash seems to have some real idiot on the development team. That is a pretty dangerous feature.

What is the behavior in tcsh? I was under the impression that the pattern was silently ignored.
That is "echo *qt*" will generate an empty string if nothing matches.

(Also, I don't consider the bash developers idiots :) There are probably reasons for choosing
this behavior -- maybe compatitibility w/ posix standards, or other. I was acutally involved a
bit with bash developement as an alpha tester early on during the mid '80s.)

wneumann
24th December 2006, 05:07 AM
Correct behavior is for the shell to simply expand the wildcard and generate the string of everything that matches, which is the empty string if nothing matches. That is logical, expected, and safe.

Anything unexpected is unsafe. And it in this case it is hard to even see a point to the illogical behavior. I can't think of any situation where I'd want it and several where it could be dangerous.