Sponsored Content
Top Forums Shell Programming and Scripting How can I search with start and end criteria? Post 302847993 by witchblade on Wednesday 28th of August 2013 08:41:12 AM
Old 08-28-2013
How can I search with start and end criteria?

Hello

I'm using cygwin and wouldlike extract information from an xml file according specific values, but don't know how.

Let's say in a file content looks like this:
Code:
 
<tab>
    SURNAME=Mustermann
    NAME=Max
    CUSTOMER SINCE= 18.01.2000
    ADDRESS=Birmingham
    DESCRIPTION=likes red
    etc
</tab>
 
<tab>
    SURNAME=Doe
    NAME=John
    CUSTOMER SINCE= 18.01.2002
    ADDRESS=Berlin
    PARAMETERX= anything
    DESCRIPTION=something
    etc
</tab>

the block starts and ends for each customer with tab /tab but the parameter in between could be different.

e.g. I want the output of all customers which has DESCRIPITON=likes red and ADDRESS starts with B

how can I define the search for both creteria is just between the start and end parameter tab?

I hope you understand what I mean Smilie

Thanks in advance

Last edited by vbe; 08-28-2013 at 10:05 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Select records based on search criteria on first column

Hi All, I need to select only those records having a non zero record in the first column of a comma delimited file. Suppose my input file is having data like: "0","01/08/2005 07:11:15",1,1,"Created",,"01/08/2005" "0","01/08/2005 07:12:40",1,1,"Created",,"01/08/2005"... (2 Replies)
Discussion started by: shashi_kiran_v
2 Replies

2. Shell Programming and Scripting

{How} Script to search a log file for a given criteria

I have to write a script to search the logfiles i.e msg.log for the following The Search Criteria is as follows 1. IP address 2. String Ex: abc.123.com 3. Timestamp ( start - end ) ex: 2008-05-04-00:30:00 - 2008-05-08-04:30:00 Can anyone help to devise a script for... (9 Replies)
Discussion started by: indiakingz
9 Replies

3. Shell Programming and Scripting

Delete new lines based on search criteria

Hi all! A bit of background: I am trying to create a script that formats SQL statements. I have gotten so far as to add new lines based on certain match criteria like commas, keywords etc. In the process, I end up adding newlines where I don't want. For example: substr(colName, 1, 10)... (3 Replies)
Discussion started by: jayarkay
3 Replies

4. Shell Programming and Scripting

awk search & delete located criteria

Guys, I manages to get awk to search and print the files that I want to delete. However I am stuck on the delete portion. Here is the command that I am using to fins these files. find /usr/local/apache/conf/vhosts/ -type f | awk '/e$/' The output is perfect. The files look like so: ... (4 Replies)
Discussion started by: jaysunn
4 Replies

5. Shell Programming and Scripting

Extract data based on specific search criteria

I have a huge file (about 2 millions records) contains data separated by “,” (comma). As part of the requirement, I can't change the format. The objective is to remove some of the records with the following condition. If the 23rd field on each line start with 302 , I need to remove that from the... (4 Replies)
Discussion started by: jaygamini
4 Replies

6. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

7. Shell Programming and Scripting

Need To Delete Lines Based On Search Criteria

Hi All, I have following input file. I wish to retain those lines which match multiple search criteria. The search criteria is stored in a variable seperated from each other by comma(,). SEARCH_CRITERIA = "REJECT, DUPLICATE" Input File: ERROR,MYFILE_20130214_11387,9,37.75... (3 Replies)
Discussion started by: angshuman
3 Replies

8. Shell Programming and Scripting

Copying section of file based on search criteria

Hi Guru's, I am new to unix scripting. I have a huge file with user details in it(file2) and I have another file with a list of users(file1). Script has to search a user from file1 and get all the associated lines from file2. Example: fiel1: cn=abc cn=DEF cn=xyx File 2: dn:... (10 Replies)
Discussion started by: Samingla
10 Replies

9. Shell Programming and Scripting

Search a String between start and end of a block in a file

Hi, I have a scenario where I want to display the output based on the pattern search between the start and end of a block in a file, we can have multiple start and end blocks in a file. Example give below, we need to search between the start block abc and end block def in a file, after that... (5 Replies)
Discussion started by: G.K.K
5 Replies

10. UNIX for Beginners Questions & Answers

Splitting week start date and end date based on custom period start dates

Below are my custom period start and end dates based on a calender, these dates are placed in a file, for each period i need to split into three weeks for each period row, example is given below. Could you please help out to achieve solution through shell script.. File content: ... (2 Replies)
Discussion started by: nani2019
2 Replies
Net::LDAP::Control::VLV(3)				User Contributed Perl Documentation				Net::LDAP::Control::VLV(3)

NAME
Net::LDAP::Control::VLV - LDAPv3 Virtual List View control object SYNOPSIS
use Net::LDAP; use Net::LDAP::Control::VLV; use Net::LDAP::Constant qw( LDAP_CONTROL_VLVRESPONSE ); $ldap = Net::LDAP->new( "ldap.mydomain.eg" ); # Get the first 20 entries $vlv = Net::LDAP::Control::VLV->new( before => 0, # No entries from before target entry after => 19, # 19 entries after target entry content => 0, # List size unknown offset => 1, # Target entry is the first ); $sort = Net::LDAP::Control::Sort->new( order => 'cn' ); @args = ( base => "o=Ace Industry, c=us", scope => "subtree", filter => "(objectClass=inetOrgPerson)", callback => &process_entry, # Call this sub for each entry control => [ $vlv, $sort ], ); $mesg = $ldap->search( @args ); # Get VLV response control ($resp) = $mesg->control( LDAP_CONTROL_VLVRESPONSE ) or die; $vlv->response( $resp ); # Set the control to get the last 20 entries $vlv->end; $mesg = $ldap->search( @args ); # Get VLV response control ($resp) = $mesg->control( LDAP_CONTROL_VLVRESPONSE ) or die; $vlv->response( $resp ); # Now get the previous page $vlv->scroll_page( -1 ); $mesg = $ldap->search( @args ); # Get VLV response control ($resp) = $mesg->control( LDAP_CONTROL_VLVRESPONSE ) or die; $vlv->response( $resp ); # Now page with first entry starting with "B" in the middle $vlv->before(9); # Change page to show 9 before $vlv->after(10); # Change page to show 10 after $vlv->assert("B"); # assert "B" $mesg = $ldap->search( @args ); DESCRIPTION
"Net::LDAP::Control::VLV" provides an interface for the creation and manipulation of objects that represent the Virtual List View as described by draft-ietf-ldapext-ldapv3-vlv-03.txt. When using a Virtual List View control in a search, it must be accompanied by a sort control. See Net::LDAP::Control::Sort CONSTRUCTOR ARGUMENTS
In addition to the constructor arguments described in Net::LDAP::Control the following are provided. after Set the number of entries the server should return from the list after the target entry. assert Set the assertion value user to locate the target entry. This value should be a legal value to compare with the first attribute in the sort control that is passed with the VLV control. The target entry is the first entry in the list which is greater than or equal the assert value. before Set the number of entries the server should return from the list before the target entry. content Set the number of entries in the list. On the first search this value should be set to zero. On subsequent searches it should be set to the length of the list, as returned by the server in the VLVResponse control. context Set the context identifier. On the first search this value should be set to zero. On subsequent searches it should be set to the context value returned by the server in the VLVResponse control. offset Set the offset of the target entry. METHODS As with Net::LDAP::Control each constructor argument described above is also avaliable as a method on the object which will return the current value for the attribute if called without an argument, and set a new value for the attribute if called with an argument. The "offset" and "assert" attributes are mutually exclusive. Setting one or the other will cause previous values set by the other to be forgotten. The "content" attribute is also associated with the "offset" attribute, so setting "assert" will cause any "content" value to be forgotten. end Set the target entry to the end of the list. This method will change the "before" and "after" attributes so that the target entry is the last in the page. response VLV_RESPONSE Set the attributes in the control as per VLV_RESPONSE. VLV_RESPONSE should be a control of type Net::LDAP::Control::VLVResponse returned from the server. "response" will populate the "context", "offset" and "content" attibutes of the control with the values from VLV_RESPONSE. Because this sets the "offset" attribute, any previous setting of the "assert" attribute will be forgotten. scroll NUM Move the target entry by NUM entries. A positive NUM will move the target entry towards the end of the list and a negative NUM will move the target entry towards the start of the list. Returns the index of the new target entry, or "undef" if the current target is identified by an assertion. "scroll" may change the "before" and "after" attributes if the scroll value would cause the page to go off either end of the list. But the page size will be maintained. scroll_page NUM Scroll by NUM pages. This method simple calculates the current page size and calls "scroll" with "NUM * $page_size" start Set the target entry to the start of the list. This method will change the "before" and "after" attributes to the the target entry is the first entry in the page. SEE ALSO
Net::LDAP, Net::LDAP::Control, Net::LDAP::Control::Sort, Net::LDAP::Control::VLVResponse AUTHOR
Graham Barr <gbarr@pobox.com> Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap@perl.org> COPYRIGHT
Copyright (c) 2000-2004 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.1 2010-03-12 Net::LDAP::Control::VLV(3)
All times are GMT -4. The time now is 08:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy