LinuxQuestions.org
Register a domain and help support LQ
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 03-11-2006, 03:36 AM   #1
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,185

Rep: Reputation: 45
Search for text inside files


Hi i want to search for the word ntua.gr in all my suse files
I have tried the following command
akroneiro:/home/alaios # grep -i '*ntua.gr*' -r /
grep: /dev/log: No such device or address


but after the first message "no such device or address" the command stops searching
 
Old 03-11-2006, 05:00 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,594

Rep: Reputation: 124Reputation: 124
find / -type f -exec grep -l -i "*ntua.gr*" {} \;
 
Old 03-11-2006, 10:43 AM   #3
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,185

Original Poster
Rep: Reputation: 45
Thx a lot for your answer... Is it possible to exclude some directories? For example the abone find command returns messages liek that
grep: /sys/devices/platform/i8042/serio0/drvctl: Permission denied
If i exclude some folders like /dev or /sys it will be much better
 
Old 03-11-2006, 11:00 AM   #4
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,594

Rep: Reputation: 124Reputation: 124
Yes, there is ... I suggest you look in the manpage of "find", there is an example you can use, search for the "-prune" option.

EDIT: Better look for the "-path" option, in my version of the manpage -prune isn't listed on it's own.

Last edited by titopoquito; 03-11-2006 at 11:03 AM.
 
Old 03-11-2006, 01:57 PM   #5
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,185

Original Poster
Rep: Reputation: 45
akroneiro:/home/alaios # find / -type f -prune /proc -exec grep -l -i "*ntua.gr*" {} \;
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
akroneiro:/home/alaios # find -prune /proc / -type f -exec grep -l -i "*ntua.gr*" {} \;
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
akroneiro:/home/alaios # find / -prune /proc -type f -exec grep -l -i "*ntua.gr*" {} \;
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
akroneiro:/home/alaios # find / -prune /dev -prune /proc -type f -exec grep -l -i "*ntua.gr*" {} \;
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
akroneiro:/home/alaios #
 
Old 03-11-2006, 02:43 PM   #6
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,594

Rep: Reputation: 124Reputation: 124
Quote:
Originally Posted by alaios
akroneiro:/home/alaios # find / -type f -prune /proc -exec grep -l -i "*ntua.gr*" {} \;
To follow the manpage and your example it should be I think

Code:
find  /  -type f -path /proc -prune -o -exec grep -l -i "*ntua.gr*" {} \;
You can give several paths to be excluded:

Code:
find  /  -type f -path /proc -prune -o -path /dev -prune -o -exec grep -l -i "*ntua.gr*" {} \;
 
Old 03-12-2006, 09:31 AM   #7
alaios
Senior Member
 
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,185

Original Poster
Rep: Reputation: 45
This doesnot work
find / -type f -path /proc -prune -o -exec grep -l -i "*ntua.gr*" {} \;
 
Old 03-12-2006, 10:20 AM   #8
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware 14.1 (32 and 64 bit)
Posts: 1,594

Rep: Reputation: 124Reputation: 124
It's nice to get a good and complete error report. Try to omit the * chars around ntua.gr.
 
  


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
Convert DOS text files to UNIX text files ta0kira Linux - Software 7 03-15-2011 12:42 PM
Perl: Search and replace directories within text files Erhnam Programming 2 03-07-2006 05:07 AM
Search text in files remotely anjanesh Red Hat 2 08-15-2005 10:03 AM
searching inside text files minm Linux - Newbie 2 01-09-2005 12:56 AM
Search all text files? nextekcarl Linux - General 4 10-20-2004 01:18 PM


All times are GMT -5. The time now is 11:05 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