LinuxQuestions.org
Visit Jeremy's Blog.
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 08-19-2012, 04:00 AM   #1
Shakthi Yokesh
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Rep: Reputation: Disabled
Linux command to find all files in a directory which contain ip addresses.


Give a Linux shell command to find all files in a directory which contain ip addresses.
 
Old 08-19-2012, 04:28 AM   #2
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,825
Blog Entries: 1

Rep: Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221
Hi and welcome to LQ.

Looks like homework. What have you tried so far?
 
Old 08-19-2012, 05:31 AM   #3
Shakthi Yokesh
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
@sycamorex: this is not a homework question.It is an interview question.I actually wrote something like
find /etc -exec grep '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \; which displays all the IP addressess present in /etc directory.......actually i just want to display the file names in which IP addressess are present....how to do that??please help me
 
1 members found this post helpful.
Old 08-19-2012, 05:38 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Have a look at grep's -L and -l options.
 
2 members found this post helpful.
Old 08-19-2012, 06:14 AM   #5
Shakthi Yokesh
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
@druuna: I could not get your clue.....It would be grateful if u provide me with the command
 
Old 08-19-2012, 06:16 AM   #6
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Did you have a look at the grep man page (man grep)?

Code:
find /etc -exec grep -L '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \;
find /etc -exec grep -l '[0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*[.][0-9][0-9]*' {} \;

Last edited by druuna; 08-19-2012 at 06:35 AM. Reason: See post #8 by sycamorex
 
Old 08-19-2012, 06:27 AM   #7
Shakthi Yokesh
LQ Newbie
 
Registered: Aug 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
@druuna: Thank u so much for your patience in explaining me this...I got the answer now....Since I am just a beginner in linux it was difficult for me to grasp your clue....once again thank u so much for helping me
 
Old 08-19-2012, 06:28 AM   #8
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,825
Blog Entries: 1

Rep: Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221Reputation: 1221
@druuna
I think the OP wants -l not -L


Try:
Code:
find /etc -exec grep -rl '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' {} \;
 
1 members found this post helpful.
Old 08-19-2012, 06:31 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by sycamorex View Post
@druuna
I think the OP wants -l not -L
Yep, you are correct!
 
  


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
LXer: Find files on Linux with the command locate LXer Syndicated Linux News 0 07-13-2012 09:30 AM
LXer: Find files on Linux with the command locate LXer Syndicated Linux News 0 07-13-2012 04:31 AM
Find directory older than x and mv directory with sub files command ajhart Linux - Newbie 4 07-15-2011 06:24 AM
linux command error message bash: /usr/bin/find: No such file or directory sundaram123 Linux - General 8 04-02-2002 08:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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