Sponsored Content
Top Forums Shell Programming and Scripting Extract Matched Records from XML Post 302962431 by Don Cragun on Monday 14th of December 2015 02:15:56 PM
Old 12-14-2015
The awk that I have (on OS X) only processes the first character in RS, but the following seems to do what you want (and should work with any version of awk, except use /usr/xpg4/bin/awk or nawk if you are using a Solaris/SunOS system):
Code:
awk '
FNR == NR {
	jn[$2]
	next
}
/<FOLDER / {
	nf = 0
	folder = $0
	next
}
/<JOB / && $6 in jn {
	copy = 1
	if(!nf++)
		print folder
}
copy
/<\/JOB>/ {
	copy = 0
	next
}
/<\/FOLDER/ && nf {
	print
}' file1 file2

This User Gave Thanks to Don Cragun For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

regex/shell script to Parse through XML Records

Hi All, I have been working on something that doesn't seem to have a clear regex solution and I just wanted to run it by everyone to see if I could get some insight into the method of solving this problem. I have a flat text file that contains billing records for users, however the records... (5 Replies)
Discussion started by: Jerrad
5 Replies

2. Shell Programming and Scripting

Grep matched records from huge file

111111111100000000001111111111 123232323200000010001114545454 232435424200000000001232131212 342354234301000000002323423443 232435424200000000001232131212 2390898994200000000001238908092 This is the record format. From 11th position to 20th position in a record there are 0's occuring,and... (6 Replies)
Discussion started by: mjkreddy
6 Replies

3. Shell Programming and Scripting

Extract records from list

Hi Gents, I have a file 1 like this 1 1000 20 2 2000 30 3 1000 40 5 1000 50 And I have other file 1 like 2 1 I would like to get from the file 1 the complete line which are in file 2, the key to compare is the column 2 then output should be. 2 2000 30. I was trying to get it... (5 Replies)
Discussion started by: jiam912
5 Replies

4. Shell Programming and Scripting

Extract a particular xml only from an xml jar file

Hi..need help on how to extract a particular xml file only from an xml jar file... thanks! (2 Replies)
Discussion started by: qwerty000
2 Replies

5. Shell Programming and Scripting

Parse xml in shell script and extract records with specific condition

Hi I have xml file with multiple records and would like to extract records from xml with specific condition if specific tag is present extract entire row otherwise skip . <logentry revision="21510"> <author>mantest</author> <date>2015-02-27</date> <QC_ID>334566</QC_ID>... (12 Replies)
Discussion started by: madankumar.t@hp
12 Replies

6. Shell Programming and Scripting

Extract strings from XML files and create a new XML

Hello everybody, I have a double mission with some XML files, which is pretty challenging for my actual beginner UNIX knowledge. I need to extract some strings from multiple XML files and create a new XML file with the searched strings.. The original XML files contain the source code for... (12 Replies)
Discussion started by: milano.churchil
12 Replies

7. Shell Programming and Scripting

Extract all the sentences that matched two patterns

Hi I have two lists of patterns named A and B consisting of around 200 entries in each and I want to extract all the sentences from a big text file which match atleast one pattern from both A and B. For example, pattern list A consists of : ama ani ahum mari ... ... and pattern... (1 Reply)
Discussion started by: my_Perl
1 Replies

8. Shell Programming and Scripting

How to fetch matched records from files between two different directory?

awk 'NR==FNR{arr;next} $0 in arr' /tmp/Data_mismatch.sh /prd/HK/ACCTCARD_20160115.txt edit by bakunin: seems that one CODE-tag got lost somewhere. i corrected that, but please check your posts more carefully. Thank you. (5 Replies)
Discussion started by: suresh_target
5 Replies

9. Shell Programming and Scripting

Extract between two Exact matched strings.

more data.txt i need this exacted from data.txt This is the command i tried sed -n "/Start_of_DISK_info:\/u/,/End_of_DISK_info:\/u/p" data.txtBut, unfortunately it does not do an exact match. Instead, it prints text between both these strings /u & /u/tmp like below. i need this... (6 Replies)
Discussion started by: mohtashims
6 Replies

10. UNIX for Beginners Questions & Answers

Extract XML block when value is matched (Shell script)

Hi everyone, So i'm struggling with an xml (log file) where we get information about some devices, so the logfile is filled with multiple "blocks" like that. Based on the <devId> i want to extract this part of the xml file. If possible I want it to have an script for this, cause we'll use... (5 Replies)
Discussion started by: Pouky
5 Replies
GJOTS2DOCBOOK(1)					      General Commands Manual						  GJOTS2DOCBOOK(1)

NAME
gjots2docbook - Convert a gjotsfile to DOCBOOK (on stdout) SYNOPSIS
gjots2docbook -a|-b [ -e ] [ -P ] [ -p ] [ gjotsfile ] DESCRIPTION
gjots2docbook converts a gjotsfile into DOCBOOK XML. gjots2docbook uses awk(1) to perform the conversion. gjots2docbook does not create them so the first element in the file should contain any <bookinfo> or <artheader> element. Similarly, <bib- liographic> elements are not created. In fact the output is very simplistic with item titles in the gjotsfile being converted to chapter or section headings in DOCBOOK. There is no reason why your gjotsfile should not contain valid DOCBOOK XML - and that is why the -e and -p op- tions are provided. If the file does not start with <?xml ...> then appropriate lines will be added as follows: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE doc_type PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"> If properly installed, the docbook utilities can then be used to create HTML, man, ps, pdf etc files eg: gjots2docbook -b ~/.gjotsfile >gjotsfile.xml docbook2pdf gjotsfile.xml It may be necessary to fine-tune the docbook formatting to access all features. OPTIONS
-a makes a DOCBOOK article -b makes a DOCBOOK book -e don't encode special characters eg < -> &lt; -p don't change blank lines to </para><para> markers -P first section is a preface rather than a chapter (book only) AUTHOR
Written by Bob Hepple <bhepple@freeshell.org> http://bhepple.freeshell.org/gjots COPYRIGHT
Copyright (c) 2002 Robert Hepple This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PAR- TICULAR PURPOSE. SEE ALSO
gjots(1), gjots2html(1), docbook2gjots(1) GJOTS2DOCBOOK(1)
All times are GMT -4. The time now is 01:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy