Sponsored Content
Top Forums Shell Programming and Scripting Extract list of IP addresses from a text file. Post 302500685 by lewk on Tuesday 1st of March 2011 09:26:32 AM
Old 03-01-2011
Extract list of IP addresses from a text file.

I have an xml file with IP addresses all over the show. I want to print only the IP addresses and cut off any text before or after the IP address.

Example:
Note: The IP addresses (x.x.x.x) do not consistently appear in the xml file as per the pattern below. Sometimes there are text before and/or after, sometimes there are two, three IP addresses per line.


Code:
 Computers   
  blah939  
    IP Address x.x.x.x 
 
  blah3938 
    IP Address x.x.x.x 
 
  blah3938
    IP Address x.x.x.x 
 
  blah9383
    IP Address x.x.x.x  
 
  blah3983 
    IP Address x.x.x.x


Output

Code:
x.x.x.x
x.x.x.x 
x.x.x.x 
x.x.x.x 
x.x.x.x 
x.x.x.x 
x.x.x.x 
x.x.x.x 
x.x.x.x

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help extracting MAC addresses from List

Hello all. I have a large number of text files outputted from various Netstumbler Wireless Scans; from which I need to extract the MAC addresses of the various Access Points. The Text files look like this: # $Creator: Network Stumbler Version 0.4.0 # $Format: wi-scan summary with... (9 Replies)
Discussion started by: dhs23
9 Replies

2. Programming

c program to extract text between two delimiters from some text file

needa c program to extract text between two delimiters from some text file. and then storing them in to diffrent variables ? text file like 0: abc.txt ========= aaaaaa|11111111|sssssssssss|333333|ddddddddd|34343454564|asass aaaaaa|11111111|sssssssssss|333333|ddddddddd|34343454564|asass... (7 Replies)
Discussion started by: kukretiabhi13
7 Replies

3. Shell Programming and Scripting

Extract IP addresses

The only way I could extract the user names and 'from' IP addresses is to use a few temp files. Split up by 'Failed keyboard-interactive' and 'Failed password'. Anyone have any idea to do this all in one go? aaa.bbb.ccc.ddd 2009-03-23 01:28:33 sshd: Failed keyboard-interactive/pam... (2 Replies)
Discussion started by: hazno
2 Replies

4. Shell Programming and Scripting

extract text from a file

I have been reading several posts regarding how to extract text from a file, but none of those have helped me for what I need. This is my problem: I need to extract the text after my pattern So my line is: 485.74 6589.5 Log likelihood: 1485.79 My pattern is 'Log likelihood:' and I need... (2 Replies)
Discussion started by: loperam
2 Replies

5. UNIX for Dummies Questions & Answers

analyzing list with street addresses

Hi List, Could someone please point me into the right direction with the following: I have a file containing a list of street addresses. I need to sort all the street addresses with the same number to a new file containing the street name and corresponding number. So: Strawinskylaan... (3 Replies)
Discussion started by: M474746
3 Replies

6. Shell Programming and Scripting

Formatting list of IP addresses into a grep command

Hi I have an input file with a list of random IP addresses, each on a new line. Below is just an example as I omitted the real IP addresses for obvious reasons. Input: random_ip.txt 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1 10.0.0.1... (7 Replies)
Discussion started by: lewk
7 Replies

7. Shell Programming and Scripting

Extract e-mail addresses on a page

Hi I normally ask questions on coding but I think there is a code that can do this. I have regular text throughout my file and I want to extract all e-mail addresses from it (rather than going and searching each one). E-mails all have @ so I assume there is a way. Thanks Phil (6 Replies)
Discussion started by: phil_heath
6 Replies

8. UNIX for Dummies Questions & Answers

List Contacted Web Addresses?

Greetings. I'm in the process of tracking down an issue with Firefox, and need some way of gathering the actual web addresses which are connected to from localhost. The specific problem centers around the determination/capture of the exact generated app.update.url address formed by the... (2 Replies)
Discussion started by: LinQ
2 Replies

9. Shell Programming and Scripting

Extract all the sentences from a text file that matches a pattern list

Hi I have a big text file. I want to extract all the sentences that matches at least 70% (seventy percent) of the words from each sentence based on a word list called A. Say the format of the text file is as given below: This is the first sentence which consists of fifteen words... (4 Replies)
Discussion started by: my_Perl
4 Replies

10. Shell Programming and Scripting

Extract sentence and its details from a text file based on another file of sentences

Hi I have two text files. The first file is TEXTFILEONE.txt as given below: <Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text> <Text Text_ID="10155645315851111_10155645317023456"... (7 Replies)
Discussion started by: my_Perl
7 Replies
snmp.conf(5)							    Apple Inc.							      snmp.conf(5)

NAME
snmp.conf - snmp configuration file for cups DESCRIPTION
The snmp.conf file configures how the standard CUPS network backends (http, https, ipp, ipps, lpd, snmp, and socket) access printer infor- mation using SNMPv1 and is normally located in the /etc/cups directory. Each line in the file can be a configuration directive, a blank line, or a comment. Comment lines start with the # character. The Community and DebugLevel directives are used by all backends. The remainder apply only to the SNMP backend (cups-snmp(8)). DIRECTIVES
The following directives are understood by the CUPS network backends. Consult the on-line help for detailed descriptions: Address @IF(name) Address @LOCAL Address address Sends SNMP broadcast queries to the specified address(es). There is no default for the broadcast address. Community name Specifies the community name to use. Only a single community name may be specified. The default community name is "public". DebugLevel number Specifies the logging level from 0 (none) to 3 (everything). Typically only used for debugging (thus the name). The default debug level is 0. DeviceURI "regular expression" device-uri [... device-uri] Specifies one or more device URIs that should be used for a given make and model string. The regular expression is used to match the detected make and model, and the device URI strings must be of the form "scheme://%s[:port]/[path]", where "%s" represents the detected address or hostname. There are no default device URI matching rules. HostNameLookups on HostNameLookups off Specifies whether the addresses of printers should be converted to hostnames or left as numeric IP addresses. The default is "off". MaxRunTime seconds Specifies the maximum number of seconds that the SNMP backend will scan the network for printers. The default is 120 seconds (2 min- utes). SEE ALSO
cups-snmp(8), http://localhost:631/help COPYRIGHT
Copyright 2007-2013 by Apple Inc. 23 April 2012 CUPS snmp.conf(5)
All times are GMT -4. The time now is 09:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy