Visit Jeremy's Blog.
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 10-18-2007, 02:53 PM   #1
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

Old 10-18-2007, 03:40 PM   #2
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

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
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927
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.



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 > Forums > Linux Forums > Linux - Newbie

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