LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   search my harddisk - which command ??? (https://www.linuxquestions.org/questions/linux-newbie-8/search-my-harddisk-which-command-266275/)

merlin23 12-14-2004 08:52 AM

search my harddisk - which command ???
 
Hello!

I want to search through my hardrive...
I always thought this is done with grep, but the syyntax I used doesn't do what I want:

grep -r "*.html" ./

I also tried grep -r --include="*.html" ./

didn't worked either...

how do I tell grep to don't search the whole file but just the names of the files in a directory... ?

EDIT:
Ok, I found out that the command find should help... but also a find ./ "*.html.pdf" for example showed me all different files that just end with html or pdf...strange behaviour...
maybe find ./ *.html | grep .pdf could help, but isn't there a possibility to make it with grep alone??

shmonkey 12-14-2004 08:59 AM

# find / -name <filename>

Regards

Shmonkey

el_pajaro! 12-14-2004 09:08 AM

To find a file use find:
Code:

find . -name *.html
This command would search from the path you are at the moment (that is there is a ".", but it could be any path). The "-name" would search for a patron in a name. So the *.html means that we would search for all files ending with .html .
The grep command is use to pick a line with an specifc patron. For example you can search with grep using a pipe from ls (I guess you try it)
Code:

ls -R path | grep .html
The "path" could be any path.

Regards,

Rafael

merlin23 12-14-2004 09:23 AM

thx very much, the find-command seems to work fine (not so the ls -R command...doesn't matter now...)

Is it also possible to redirect this output to the rm-command ?

find . -name *.html | rm

doesn't work....

twantrd 12-14-2004 11:35 AM

It would be:

find . -name *.html | xargs rm

-twantrd

anoopp 12-14-2004 11:46 AM

hi

use command locate or slocate

for mre info try out man locate


All times are GMT -5. The time now is 02:38 AM.