I am looking for something similar to the windows SEARCH FILES comman with the option "files containing ..." (that is where I can specify a string and it will find all files containing that string -- not just having the string as part of the name but actually containing it in the text).
Is there some way to do this?
On Fri, October 3, 2008 10:00 am, tony.chamberlain@lemko.com wrote:
I am looking for something similar to the windows SEARCH FILES comman with the option "files containing ..." (that is where I can specify a string and it will find all files containing that string -- not just having the string as part of the name but actually containing it in the text).
Is there some way to do this?
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
I would recommend taking a look at grep. THere are many ways you can use it. Bo
On Fri, Oct 3, 2008 at 6:54 AM, Bo Lynch blynch@ameliaschools.com wrote:
On Fri, October 3, 2008 10:00 am, tony.chamberlain@lemko.com wrote:
I am looking for something similar to the windows SEARCH FILES comman with the option "files containing ..." (that is where I can specify a string and it will find all files containing that string -- not just having the string as part of the name but actually containing it in the text).
Is there some way to do this?
I would recommend taking a look at grep. THere are many ways you can use it.
One such example is:
find . -type f -exec grep -il !* {} ; -exec grep -i !* {} ; -exec echo ;
alias it to, say, findword and run: findword <text>
It will show the file names as well as the lines that contain the text.
Akemi
On Fri, Oct 3, 2008 at 7:24 AM, Akemi Yagi amyagi@gmail.com wrote:
On Fri, Oct 3, 2008 at 6:54 AM, Bo Lynch blynch@ameliaschools.com wrote:
I would recommend taking a look at grep. THere are many ways you can use it.
One such example is:
find . -type f -exec grep -il !* {} ; -exec grep -i !* {} ; -exec echo ;
alias it to, say, findword and run: findword <text>
Sorry, I missed the "!" in the above paste:
find . -type f -exec grep -il !* {} ; -exec grep -i !* {} ; -exec echo ;
On Fri, Oct 3, 2008 at 7:27 AM, Akemi Yagi amyagi@gmail.com wrote:
On Fri, Oct 3, 2008 at 7:24 AM, Akemi Yagi amyagi@gmail.com wrote:
On Fri, Oct 3, 2008 at 6:54 AM, Bo Lynch blynch@ameliaschools.com wrote:
I would recommend taking a look at grep. THere are many ways you can use it.
One such example is:
find . -type f -exec grep -il !* {} ; -exec grep -i !* {} ; -exec echo ;
alias it to, say, findword and run: findword <text>
Sorry, I missed the "!" in the above paste:
find . -type f -exec grep -il !* {} ; -exec grep -i !* {} ; -exec echo ;
I tend to do this:
find . -type f -exec grep <pattern> /dev/null {} ;
The "/dev/null" is because grep doesn't show the file name unless there are at least two provided, and this accomplishes what Akemi's command above does but in a single command. Of course, it still takes forever if the directory whence the search begins is /.
mhr
Akemi Yagi wrote:
find . -type f -exec grep -il !* {} ; -exec grep -i !* {} ; -exec echo ;
alias it to, say, findword and run: findword <text>
Sorry, I missed the "!" in the above paste:
find . -type f -exec grep -il !* {} ; -exec grep -i !* {} ; -exec echo ;
If you are using GNU grep (well, you are using CentOS),
grep -ri "foo" dir/to/search/in
seems much shorter to me.
Cheers,
Ralph
On Mon, Oct 6, 2008 at 2:41 AM, Ralph Angenendt ra+centos@br-online.de wrote:
If you are using GNU grep (well, you are using CentOS),
grep -ri "foo" dir/to/search/in
seems much shorter to me.
Without the -H you don't get the file names....
mhr
MHR wrote:
On Mon, Oct 6, 2008 at 2:41 AM, Ralph Angenendt ra+centos@br-online.de wrote:
If you are using GNU grep (well, you are using CentOS),
grep -ri "foo" dir/to/search/in
seems much shorter to me.
Without the -H you don't get the file names....
Hu?
| [angenenr@shutdown httpd]$grep -ri virtu conf* | grep -v "#" | conf.d/ssl.conf:<VirtualHost _default_:443> | conf.d/ssl.conf:</VirtualHost> | [angenenr@shutdown httpd]$grep -rHi virtu conf* | grep -v "#" | conf.d/ssl.conf:<VirtualHost _default_:443> | conf.d/ssl.conf:</VirtualHost>
Cheers,
Ralph
On Mon, Oct 6, 2008 at 9:26 AM, Ralph Angenendt ra+centos@br-online.de wrote:
Hu?
| [angenenr@shutdown httpd]$grep -ri virtu conf* | grep -v "#" | conf.d/ssl.conf:<VirtualHost _default_:443> | conf.d/ssl.conf:</VirtualHost> | [angenenr@shutdown httpd]$grep -rHi virtu conf* | grep -v "#" | conf.d/ssl.conf:<VirtualHost _default_:443> | conf.d/ssl.conf:</VirtualHost>
Doh! Of course - -r implies multiple files, so without -h you _will_ get them.
Homer moment.
mhr
On 6 Oct 2008, at 09:33, MHR wrote:
On Mon, Oct 6, 2008 at 9:26 AM, Ralph Angenendt <ra+centos@br-online.de
wrote:
Hu?
| [angenenr@shutdown httpd]$grep -ri virtu conf* | grep -v "#" | conf.d/ssl.conf:<VirtualHost _default_:443> | conf.d/ssl.conf:</VirtualHost> | [angenenr@shutdown httpd]$grep -rHi virtu conf* | grep -v "#" | conf.d/ssl.conf:<VirtualHost _default_:443> | conf.d/ssl.conf:</VirtualHost>
Doh! Of course - -r implies multiple files, so without -h you _will_ get them.
Shorter still=P
[jf@betty conf.d]$ grep -i virtu * ssl.conf:## the main server and all SSL-enabled virtual hosts. ssl.conf:## SSL Virtual Host Context ssl.conf:<VirtualHost _default_:443> ssl.conf:# General setup for the virtual host, inherited from global configuration
Filenames show even if a grep of many files only returns one result [jf@betty conf.d]$ grep -i "loadmodule ssl" * ssl.conf:LoadModule ssl_module modules/mod_ssl.so
Jeremiah
Jeremiah Heller wrote:
On 6 Oct 2008, at 09:33, MHR wrote:
On Mon, Oct 6, 2008 at 9:26 AM, Ralph Angenendt <ra+centos@br-online.de
| [angenenr@shutdown httpd]$grep -ri virtu conf* | grep -v "#" | conf.d/ssl.conf:<VirtualHost _default_:443> | conf.d/ssl.conf:</VirtualHost>
Doh! Of course - -r implies multiple files, so without -h you _will_ get them.
Shorter still=P
[jf@betty conf.d]$ grep -i virtu *
That might be shorter, but doesn't recurse down a directory tree (as was required by the original poster).
Ralph
On Mon, Oct 6, 2008 at 2:41 AM, Ralph Angenendt ra+centos@br-online.de wrote:
Akemi Yagi wrote:
Sorry, I missed the "!" in the above paste:
find . -type f -exec grep -il !* {} ; -exec grep -i !* {} ; -exec echo ;
If you are using GNU grep (well, you are using CentOS),
grep -ri "foo" dir/to/search/in
seems much shorter to me.
This works unless you are looking to search a specific set of files by name, not just whole directories.
I routinely use searches like this to locate patterns in build trees, but I typically only want to look in header or c source files (or sometimes just the Makefiles. In my case, the find...grep form works better because there may not be any of the files I want in the directory from which I begin the search, only those farther down.
Cheers.
mhr
tony.chamberlain@lemko.com írta:
I am looking for something similar to the windows SEARCH FILES comman with the option "files containing ..." (that is where I can specify a string and it will find all files containing that string -- not just having the string as part of the name but actually containing it in the text).
Is there some way to do this?
exec + *grep ?
t
tony.chamberlain@lemko.com a écrit :
I am looking for something similar to the windows SEARCH FILES comman with the option "files containing ..." (that is where I can specify a string and it will find all files containing that string -- not just having the string as part of the name but actually containing it in the text).
Is there some way to do this?
grep is your friend. Let's say you are looking for the character string 'UserDir' below your /etc directory. Then you would simply do:
[root@grossebertha ~]# grep -R UserDir /etc/
Give it a try!
Niki
On Fri, 2008-10-03 at 16:04 +0200, Niki Kovacs wrote:
tony.chamberlain@lemko.com a écrit :
I am looking for something similar to the windows SEARCH FILES comman with the option "files containing ..." (that is where I can specify a string and it will find all files containing that string -- not just having the string as part of the name but actually containing it in the text).
Is there some way to do this?
grep is your friend. Let's say you are looking for the character string 'UserDir' below your /etc directory. Then you would simply do:
[root@grossebertha ~]# grep -R UserDir /etc/
If that might put out a lot and you want only a list of file names, add
-l or --files-with-matches
<snip>
tony.chamberlain@lemko.com schrieb:
I am looking for something similar to the windows SEARCH FILES comman with the option "files containing ..." (that is where I can specify a string and it will find all files containing that string -- not just having the string as part of the name but actually containing it in the text).
Is there some way to do this?
You could use "glimpse" for that. Or google desktop ;-)
The problem is that preparing the index takes a lot of time. And more than 95 time out of 100, you don't need it anyway. (On a server, because man -k and locate already do a good job of making the relevant stuff available to you quickly).
Rainer
tony.chamberlain@lemko.com wrote:
I am looking for something similar to the windows SEARCH FILES comman with the option "files containing ..." (that is where I can specify a string and it will find all files containing that string -- not just having the string as part of the name but actually containing it in the text).
Is there some way to do this?
Under KDE, there is the "Find Files/Folders" option on the main menu that will do exactly this, or did you want something from the command line?
I don't use gnome, but I would expect it to have something similar.