Jump to content

Google-search (well not really) on KDE


devries
 Share

Recommended Posts

Google search is a clever way to search files on your PC. Unfortunately there isn't yet a Linux equivalant so we on Mandrake are a bit behind. However Linux has the 'locate' command that we can use and as long as we give our files meaningfull names that works quite well. All we need now is a nice way to integrate this command in KDE. Fortunately that way has arrived.

 

-1- Install the Kio-locate program (link)

-2- Open Konqueror, go to 'setting', go to 'preferences', go to 'web-associations' and make 'locate search for local files' the default search engine.

 

Now type something in the adress bar, give <enter> and there are your files. :)

 

Note: with kcron (another nice KDE program) you can automate the 'updatedb' command (once every night) so you will always find what you need.

Link to comment
Share on other sites

find . -print | xargs grep -si 'Monday morning meeting'

above searches recursively down through the directory tree below your current position on the command line.

 

grep -sril 'Monday morning meeting' ./*

 

does exactly the same *but* in a single command ;)

 

and even if you need to use find, xargs is superfluous, ie:

 

find . -iname '*.txt' -exec grep -isl "Monday morning meeting" {} \;

Link to comment
Share on other sites

find . -print | xargs grep -si 'Monday morning meeting'

above searches recursively down through the directory tree below your current position on the command line.

 

grep -sril 'Monday morning meeting' ./*

 

does exactly the same *but* in a single command ;)

 

and even if you need to use find, xargs is superfluous, ie:

 

find . -iname '*.txt' -exec grep -isl "Monday morning meeting" {} \;

 

but they give differently output formats (extracts are shortened for clarity):

 

find . -print | xargs grep -s 'blog'

output : file , result

 

./class.bloggerclient.php:function blogger_checkFaultString($bloggerResult) {

./class.bloggerclient.php: if ($bloggerResult["faultString"]) {

./class.bloggerclient.php: return $bloggerResult["faultString"];

./class.bloggerclient.php: else if (strpos($bloggerResult, "java.lang.Exception") !== false) {

./class.bloggerclient.php: return $bloggerResult;

 

grep -sril 'blog' ./*

 

output: file

 

./bloggerFunctions/blogger.php

./bloggerFunctions/Readme.txt

./bloggerFunctions.zip

 

 

find . -iname '*.php' -exec grep -isi "blog" {} \;

 

output: file content match

 

// If the user only has one blog, then it returns a string containing the name of the blog

// in plain text, with a hidden form input containing the blogid, using the same

function getUsersBlogsSelect($name="blog", $selected="", $extra="")

$getUsersBlogsArray = $this->getUsersBlogs();

 

 

and no it doesnt integrate into kde - although you could pipe the results to dcop and display them in kedit maybe - or just add ">output.txt" to pipe to a file and just open up in your favourite editor.

Link to comment
Share on other sites

but they give differently output formats (extracts are shortened for clarity):

 

find . -print | xargs grep -s 'blog'

output : file , result

...

 

grep -sril 'blog' ./*

 

output: file

...

play with options, I answered from memory...but here you are:

 

grep -sri 'blog' ./*

 

outputs -> file: string

 

---> man grep or even better egrep ;)

 

find . -iname '*.php' -exec grep -isi "blog" {} \;

 

output: file content match

again I was coding from memory, the right command is with two {} {}:

 

find . -iname '*.php' -exec grep -si "blog" {} {} \;

 

sorry for posting w/o testing before :mr-green:

 

and no it doesnt integrate into kde - although you could pipe the results to dcop and display them in kedit maybe - or just add ">output.txt" to pipe to a file and just open up in your favourite editor.

 

I have no idea of KDE, and even less about KDE integration, but as an exercise for the boring people, here is a "graphical tool" :lol:

 

#! /bin/bash

COMMON="--title $0"

SEARCHSTR="$(Xdialog $COMMON --inputbox "String to search in your /home tree" 10 30 2>&1)"

# results:

find ~/ -exec grep -si "$SEARCHSTR" {} {} \; |\

Xdialog $COMMON --backtitle "may take a while" --logbox - 40 60

 

Disclaimer: don't correct the script because it hasn't been tested, so probably it wont work ;)

Edited by aru
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...