LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 15
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??

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

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

Regards

Shmonkey
 
Old 12-14-2004, 10:08 AM   #3
el_pajaro!
Member
 
Registered: Sep 2003
Location: Ecuador
Distribution: Debian, Ubuntu, Elastix
Posts: 183

Rep: Reputation: 30
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
 
Old 12-14-2004, 10:23 AM   #4
merlin23
Member
 
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, 12:35 PM   #5
twantrd
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

-twantrd
 
Old 12-14-2004, 12:46 PM   #6
anoopp
LQ Newbie
 
Registered: May 2004
Posts: 14

Rep: Reputation: 0
hi

use command locate or slocate

for mre info try out man locate
 
  


Reply


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 10:46 AM
search using description to get command? Linuxuser_81 Linux - Newbie 1 10-07-2005 01:59 PM
Is it possible to search for a string from all the files on the harddisk? Akhran Linux - Newbie 8 09-13-2005 07:09 AM
command to query harddisk models sausagejohnson Linux - Hardware 2 08-31-2005 09:45 PM
search for command needed by taztv gaja Linux - Newbie 1 12-29-2001 02:04 PM


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

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