It would be much helpful, if you can explain the command as what it does in detail. Since being newbie I finding it difficult to understand the commands used.
Since, most UNIX text processing utilities on some systems have line length limitations of approximately 2048 bytes per line (and you have told us that your system has a limit of 3000 bytes per line in sed), we have to assume that you can't process this input file in the normal ways. Although, it is very confusing for you to give us an 881 byte file and tell us that utilities are complaining because it contains a line that is longer than 3000 bytes???
We can get around awk's line length limitations by setting a record separator that will select records that are shorter than its line length limit. With your sample xml file we can use the > as the record separator and get lots of short records instead of a single 3000+ byte long line.
With the data you're trying to capture being of the form:
the text shown in red will be in previous records or following records. By setting the field separator to the string </corspd_num, any record that has two fields with have the data that you want as the 1st field in that record and an empty field as the 2nd field on that line. Any record that does not contain the field separator string will either have zero fields or one field. So the code:
invokes awk
with the input field separator set to </corspd_num (specified by -F'</corspd_num'),
the input record separator set to > (specified by -v RS='>'),
the script to be evaluated set to 'NF > 1{print $1}', and
the file to be processed specified by DRIVER_TagString.
And the script NF > 1{print $1} says that for each record found in the input file, if the number of fields found in that record (NF) is more than 1 (NF > 1) then print (print) the 1st field from that record ($1). Other records in the file are skipped over without printing anything.
I have this XML file format and all in one line:
Fri Dec 23 00:14:52 2016 Logged Message:689|<?xml version="1.0" encoding="UTF-8"?><PORT_RESPONSE><HEADER><ORIGINATOR>XMG</ORIGINATOR><DESTINAT... (16 Replies)
I want to check if every <Part> element has corresponding <Description> in this sample XML.
....<Lot Of XML>
<Inv lineNumber="2">
<Item>
... (4 Replies)
Any help to extract the root element from an XML file will be appreciated.
Example: test.xml
<?xml version="1.0" encoding="utf-8" ?>
<TestXMLMessage>
<TestRec>
<ID>1000</ID>
</TestRec>
</TestXMLMessage>
Wanted to extract the TestXMLMessage.
Regards,
Chari (6 Replies)
Hi,
Within a UNIX shell script I need to extract a value from an XML field. The field will contain different values but will always be 6 digits in length. E.g.:
<provider-id>999999</provider-id>
I've tried various ways but no luck. Any ideas how I might get the provider id (in this case... (2 Replies)
Hi, I would need to read an xml element from an xml file to a local variable. Please could you help me with a shell script to get so? Considering that I have a file called file.xml like below:
<header>
<description>This is the description</description>
<content>This is the... (2 Replies)
I have a rather large file with XML-style content. Each line contains one full XML entry. For example:
1:<Message><DNIS>1234</DNIS><UCID>3456</UCID><TransferGroup>XYZXYZ</TransferGroup></Message>
2:<Message><DNIS>9999</DNIS><UCID>2584</UCID><TransferGroup>ABCABC</TransferGroup></Message>... (1 Reply)
Hi All,
I am looking for a awk/shell which can find an element named REFERENCE in a XML file and check whether it is empty or not.
If there is no value in the REFERENCE element then correspondingly move the file to some other folder.
The Unix server is AIX version 4.
Any inputs... (9 Replies)
I have some xml files that got created by exporting a website from RedDot. I would like to extract the cost,
course number, description, and meeting information.
<?xml version="1.0" encoding="UTF-16" standalone="yes" ?>
- <PAG PAG0="3AE6FCFD86D34896A82FCA3B7B76FF90" PAG3="525312"... (3 Replies)