[SOLVED] Grep IP's from xml with name of file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users [SOLVED] Grep IP's from xml with name of file
# 1  
Old 09-27-2013
[SOLVED] Grep IP's from xml with name of file

Hi all,
actually i have a lot of IP addresses on multiple .xml files on my folder,

my tag on xml files are like this,
Code:
<db-url>jdbc:oracle:thin:@10.100.5.56:1521:DWH01</db-url>

i actually can print only the IP addresses

Code:
awk -F"[<>]" '/url/ { print $3 }' *.xml
10.100.5.56

i would like to grep all the IP addresses and also the name of the file like this

Code:
my_new_config.xml 10.100.5.56:1521:DWH01

is this possible?

Thanks in advance.

Last edited by charli1; 09-27-2013 at 10:12 AM..
# 2  
Old 09-27-2013
Yes, in awk use internal variable FILENAME
So
Code:
awk -F"[<>]" '/url/ { print FILENAME FS $3 }'

These 2 Users Gave Thanks to Peasant For This Post:
# 3  
Old 09-27-2013
thanks a lot mate.

Solved.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep error "No such file or directory" not solved

Dear all, I run a simple command: grep -f GTEx_snps.txt chr1_r2.txt>chr1_r2_GTEx.txt and got error: "chr1_r2_GTEx.txt: No such file or directory" while "chr1_r2_GTEx.txt is an non-existent file. I google searched some solutions and tried to add -s and --no-messages option grep -s... (2 Replies)
Discussion started by: forevertl
2 Replies

2. Shell Programming and Scripting

Grep some values from XML file

Dear community, I have a big XML log file containing several rows splitted by tag: <ActivityLogRecord> and </ActivityLogRecord>. An example below. What I need is read the file and extract some value from each tags and put them into one line (each line for every <ActivityLogRecord> tag). So... (5 Replies)
Discussion started by: Lord Spectre
5 Replies

3. UNIX for Dummies Questions & Answers

Grep content in xml file

I have an xml file with header as below. <Provider xmlns="http://www.xyzx.gov/xyz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyzx.gov/xyz xyz.xsd" SCHEMA_VERSION="2.5" PROVIDER="5"> I want to get the schema version here that is 2.5 and put in a... (7 Replies)
Discussion started by: Ariean
7 Replies

4. UNIX for Dummies Questions & Answers

[Solved] How remove leading whitespace from xml (sed /awk?)

Hi again I have an xml file and want to remove the leading white space as it causes me issues later in my script I see sed is possible but cant seem to get it to work I tried sed 's/^ *//' file.xml output <xn:VsDataContainer id="1U104799" modifier="update"> ... (10 Replies)
Discussion started by: aniquebmx
10 Replies

5. UNIX for Dummies Questions & Answers

GREP for a tag in XML File

I have 2 XML Data files with a tag named PARTICIPATION_TYPE and i am trying to grep for that and getting unique values. However one of the xml data file data is not aligned properly like below. File 1: (works fine when i do grep) grep "PARTICIPATION_TYPE" file1.xml | sort -u Data: ....... (3 Replies)
Discussion started by: Ariean
3 Replies

6. Shell Programming and Scripting

Grep/Parse a .xml file

I have a .xml file similar to the following: <Column> <Name>FIELD1</Name> <Title>CO.</Title> </Column> <Column> <Name>FIELD2</Name> <EditField>TextBox</EditField> <ColumnSpan0>4</ColumnSpan0> <Title>NORMAL</Title> ... (12 Replies)
Discussion started by: jl487
12 Replies

7. Shell Programming and Scripting

[SOLVED] Read XML for solaris

Hello I have this script that works fine in Linux But not on sun solaris. Can some one help me with the awk syntax for solaris. Linux: awk -F $0~/DBURL/ {print $7} /tmp/test.xml---------- Post updated at 11:16 AM ---------- Previous update was at 11:05 AM ---------- Sorry guys i got the... (0 Replies)
Discussion started by: pradeepmacha
0 Replies

8. Shell Programming and Scripting

[Solved] Line Break Issue for an XML file

I got an XML file(file name TABLE.xml) which the data format has line breaks(with no Spaces, no Nulls, no characters between each line), I need to write a KSH script which gives me the data in single line as format shown below My input file which have line breaks: <TABLE> <TABLE-ROW> <S_NO>... (7 Replies)
Discussion started by: pred55
7 Replies

9. Shell Programming and Scripting

[Solved] perl and grep: get a script to look at more then one file

hi guys i have this very messy script, that looks in /var/log/messages.all for an error and reports if it finds the key works how can i get it to look at more then one file, i.e /var/log/message.all * so it looks in old logs as well thanks exit 0 if (isRenderNode(hostname)); my... (4 Replies)
Discussion started by: ab52
4 Replies

10. Shell Programming and Scripting

How to grep multiple pattern from XML file

Hi Everyone pls if anyone can help me in writing a script or correcting it what I have done. I want to write a script to grep record number for all those record which have abc xyd cat dog in one of the field say VALUE, I have thousand of file in a dir and I want to search every file for... (6 Replies)
Discussion started by: revertback
6 Replies
Login or Register to Ask a Question