Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-14-2004, 08:52 AM   #1
Registered: Dec 2004
Location: Vienna
Posts: 46

Rep: Reputation: 15
search my harddisk - which command ???


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... ?

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??

Last edited by merlin23; 12-14-2004 at 08:58 AM.
Old 12-14-2004, 08:59 AM   #2
Registered: Nov 2004
Location: UK
Distribution: Ubuntu
Posts: 118

Rep: Reputation: 15
# find / -name <filename>


Old 12-14-2004, 09:08 AM   #3
Registered: Sep 2003
Location: Ecuador
Distribution: Debian, Ubuntu, Elastix
Posts: 183

Rep: Reputation: 30
To find a file use find:
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)
ls -R path | grep .html
The "path" could be any path.


Old 12-14-2004, 09:23 AM   #4
Registered: Dec 2004
Location: Vienna
Posts: 46

Original Poster
Rep: Reputation: 15
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....
Old 12-14-2004, 11:35 AM   #5
Senior Member
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
It would be:

find . -name *.html | xargs rm

Old 12-14-2004, 11:46 AM   #6
LQ Newbie
Registered: May 2004
Posts: 14

Rep: Reputation: 0

use command locate or slocate

for mre info try out man locate


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
command to search ekdya Linux - Newbie 3 11-12-2005 09:46 AM
search using description to get command? Linuxuser_81 Linux - Newbie 1 10-07-2005 12:59 PM
Is it possible to search for a string from all the files on the harddisk? Akhran Linux - Newbie 8 09-13-2005 06:09 AM
command to query harddisk models sausagejohnson Linux - Hardware 2 08-31-2005 08:45 PM
search for command needed by taztv gaja Linux - Newbie 1 12-29-2001 01:04 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:09 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration