- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: xml search/parse script
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
Forums
Discussions
Discussions
Discussions
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
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
09-14-2001 02:09 AM
09-14-2001 02:09 AM
1 street
2 street
Now I'd like to do a search on
Say 'Paddy' and find out 'HowMany' are due and in which 'Shop' to order through script.
Something like this:
#./script Paddy
You get Paddy in SpiritStore, 2 street and you need 2
Have a great day!!
#
Any ideas on how to proceed!?
All suggestions welcome/rewarded!
Later,
Bill
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 03:05 AM
09-14-2001 03:05 AM
Solutioncreate awk script as follows:
================================
$0 ~ search{GOTIT=1}
/
//{GOTNAME=NAME;ADDRESS=substr($0,10,length($0)-20)}
/
if (GOTIT == 1) {print "You get",NAME,"in",ADDRESS,"and you need",HOWMANY};GOTIT=0}
==============================
and run it with:
awk -f above-script search=Paddy inputfile
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 03:17 AM
09-14-2001 03:17 AM
Re: xml search/parse script
Sorry, the last line should read:
if (GOTIT == 1) {print "You get",NAME,"in",GOTNAME",",ADDRESS,"and you need",HOWMANY};GOTIT=0}
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 04:09 AM
09-14-2001 04:09 AM
Re: xml search/parse script
Thanks Robin.
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 04:16 AM
09-14-2001 04:16 AM
Re: xml search/parse script
And no, that wasn't a deliberately-forget-something-to-get-more-points reply, but thanks anyway!!
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 04:58 AM
09-14-2001 04:58 AM
Re: xml search/parse script
I need your help a bit more!
I changed the text to match my xml files and am getting some problems..
This is the real text:
The o/p should be
A search for lets say
returning within
data_00_33
---------------------
-
+
+
+
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 05:22 AM
09-14-2001 05:22 AM
Re: xml search/parse script
You get in , and you need
You get in , and you need
awk script:
$0 ~ search{GOTIT=1}
/
/
/
if (GOTIT == 1) {print "You get",VALUE,"in",GOTNAME",",TRUNKGROUP,"and you need"
,TRANSPORTMAPPING};GOTIT=0}
xml attached
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 06:37 AM
09-14-2001 06:37 AM
Re: xml search/parse script
Try this:
=============================
$0 ~ "
{sub(/^ */,"",$0)}
/
/
/
if (GOTIT == 1) {print "You get",VALUE,"in Trunkgroup",
TRUNKGROUP,"and you need Mapping",TRANSPORTMAPPING};GOTIT=0}
=============================
The file you attached was slightly different to the initial format in that, for instance
If you want to play with the script, the figure in the substr function is the length of the search string + 1, e.g.
The sub at the beginning removes leading spaces. I also assume you only want to search on the
Anyway, give it a go, let me know of any problems.
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 06:59 AM
09-14-2001 06:59 AM
Re: xml search/parse script
In anycase, The o/p is something like the following now, which is perfectly correct... but just for cosmetic reasons, how could I get rid of the and others.. without limiting the fields to character lengths..
CIC: 12345678 found
Trunkgroup: TG_00_00
Transport Mapping: pereal.0.0.0
Thanks again,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 07:20 AM
09-14-2001 07:20 AM
Re: xml search/parse script
OK, sounds like I was working on a slightly different file format, but it's easy enough to remove the trailing strings.
If you have a look back to my original script, I have a third argument to the substr function - this tells awk to only output a string of this length. This will equal the length of the original line, length($0), minus the length of, say,
Got to dash now, but hopefully that will help.
Rgds, Robin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2001 07:21 AM
09-14-2001 07:21 AM
Re: xml search/parse script
Thanks for the help.
Bill