LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-02-2014, 05:27 AM   #1
RMS#
LQ Newbie
 
Registered: Apr 2014
Posts: 5

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


i read about general ip address finding but i want to find ip address 192.168.x.x in all files which contains.Thanks your answers

Linux command to find all files in a directory which contain ip addresses like 192.168.x.x
 
Old 04-02-2014, 05:34 AM   #2
Drakeo
Senior Member
 
Registered: Jan 2008
Location: Urbana IL
Distribution: Slackware, Slacko,
Posts: 3,092
Blog Entries: 3

Rep: Reputation: 324Reputation: 324Reputation: 324Reputation: 324
http://en.wikipedia.org/wiki/Grep
 
Old 04-02-2014, 05:53 AM   #3
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 521

Rep: Reputation: 141Reputation: 141
1. Lazy way:
Code:
$ grep '192.168.' /directory/*
2. Specific way:
Code:
$ export IP4a='192.168.\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){1}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b'
$ grep -E "$IP4a" /directory/*
3. Perfect way (any ip, but only ip4):
Code:
$ export IP4='\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b'
$ grep -E "$IP4" /directory/*
 
1 members found this post helpful.
Old 04-02-2014, 06:57 AM   #4
RMS#
LQ Newbie
 
Registered: Apr 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
thanks your answers but i take error :

/directory/* : no such file or directory
 
Old 04-02-2014, 09:17 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,438

Rep: Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842Reputation: 2842
Quote:
/directory/* : no such file or directory
This was to be an example which you would need to replace with the directory YOU want to use.
 
1 members found this post helpful.
  


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
Linux command to find all files in a directory which contain ip addresses. Shakthi Yokesh Linux - Newbie 8 08-19-2012 05:31 AM
LXer: Find files on Linux with the command locate LXer Syndicated Linux News 0 07-13-2012 03:31 AM
Find directory older than x and mv directory with sub files command ajhart Linux - Newbie 4 07-15-2011 05:24 AM
linux command error message bash: /usr/bin/find: No such file or directory sundaram123 Linux - General 8 04-02-2002 07:18 AM


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