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 10-18-2007, 02:53 PM   #1
DeeH
LQ Newbie
 
Registered: Oct 2007
Posts: 2

Rep: Reputation: 0
Question Need help with finding pattern in files


I am a very new Linux user and I need some assistance with finding something in the file system. My predessor left me instructions which were lost when our office was rearranged.
Basically I want to find all files in my system that contain the string '172.' I know this may be fairly large, so I would like to write the results to a text file.

I've tried

find / -type f -exec grep -lins "172." > dar172.txt {} \;

but it seems to go away and never comeback and of course I can't find dar172.txt anywhere on the system.

Thanks so much for any assistance

Dee
 
Old 10-18-2007, 03:40 PM   #2
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 14.1
Posts: 446

Rep: Reputation: 59
I can't really see the point in exec the grep command, perhaps I have missed a point here. This would work:

find / -type f -name '*172.*' > dar172.txt

Edit:
Ah, If you want linenumbers, then this will do the trick:
find / -type f -name '*172.*' | grep -n "" > dar172.txt

Last edited by Dinithion; 10-18-2007 at 03:54 PM.
 
Old 10-18-2007, 07:00 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
No need to "find", really ...

grep -rnI 172 /etc/* /var/* /usr/local/* > dar172.txt

The reason that "find never comes back" may well be due to the
fact that you're going over /dev and/or /proc .... hence the
list of "sensible places" to look in.



Cheers,
Tink
 
  


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
list all files *not* containing pattern code-breaker Linux - General 8 05-03-2007 01:07 PM
finding multiple occurances of a pattern sharad Linux - General 3 05-24-2006 04:23 PM
How to recursively rename files using their directory name pattern ceg4048 Linux - General 2 09-28-2005 02:16 PM
list files NOT matching a pattern smart_sagittari Linux - Newbie 9 05-20-2005 06:32 AM
search for pattern in files and replace mizuki26 Linux - Newbie 3 01-04-2004 12:57 PM


All times are GMT -5. The time now is 08:50 AM.

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