- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: script to search an xml file and output all se...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2010 05:10 AM
тАО08-12-2010 05:10 AM
I'm looking for a way to query an xml file for a particular property with content such as follows:
The result of the query for
script.sh 12345
for example would be
How could this be done with sed/awk and other standard tools!
Thanks for any help suggestions.
Regards,
Bill
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2010 09:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2010 12:58 PM
тАО08-12-2010 12:58 PM
Re: script to search an xml file and output all sections containing input string.....
# cat ./myfilter
#!/usr/bin/perl
use strict;
use warnings;
my $pattern = shift or die;
undef $/;
my $xml = ;
for ( split( /
print "
}
1;
...run as:
# ./myfilter 12345 file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2010 08:47 PM
тАО08-12-2010 08:47 PM
Re: script to search an xml file and output all sections containing input string.....
Great thanks for your rapid answers.
James, I got an error with your script with the input.xml shown above...
My perl isn't good enough to correct it yet!
[root@oces01 scripts]# ./searchCDR.2.sh 12345 cdr.xml
Name "main::DATA" used only once: possible typo at ./searchCDR.2.sh line 6.
readline() on unopened filehandle DATA at ./searchCDR.2.sh line 6.
Use of uninitialized value in split at ./searchCDR.2.sh line 7.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2010 04:31 AM
тАО08-13-2010 04:31 AM
Re: script to search an xml file and output all sections containing input string.....
> James, I got an error with your script with the input.xml shown above...
Yes, my apologies. Change the line that reads:
my $xml = ;
...to be:
my $xml = <>;
The use of allowed me to include your actual data as a part of the script by adding it at the script's end with the prepended line '__DATA__'. When I dropped this I meant to make the change above to enable one or more files to be read from the command line.
Regards!
...JRF...