Sponsored Content
Top Forums Shell Programming and Scripting print the last line of an recurring pattern on the 3rd field Post 302487196 by ux4me on Tuesday 11th of January 2011 04:29:46 PM
Old 01-11-2011
print the last line of an recurring pattern on the 3rd field

How can i awk/sed to print the last line of an recurring pattern on the 3rd field?

Input lines:
Code:
123456.1 12 1357911 11111.1 01
123456.2 12 1357911 11111.2 02
123456.3 12 1357911 11111.3 03
123456.4 12 1357911 11111.4 04
123456.5 12 1357911 11111.5 05
246810.1 12 1357911 22222.1 01
246810.2 12 1357911 22222.2 02
246810.3 12 1357911 22222.3 03
789101.1 12 1357911 33333.1 01
789101.2 12 1357911 33333.2 02
789101.3 12 1357911 33333.3 03
789101.4 12 1357911 33333.4 04
789101.5 12 1357911 33333.5 05

Desired output:
Code:
123456.5 12 1357911 11111.5 05
246810.3 12 1357911 22222.3 03
789101.5 12 1357911 33333.5 05

Please assist and thanking you in advance.

---------- Post updated at 04:29 PM ---------- Previous update was at 04:19 PM ----------

i think i found the answer on this link - change to $3 instead of $1
https://www.unix.com/shell-programmin...eld-match.html

.. test in progress..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print 3rd to last line of file?

Hi, I have a ksh script I would like to modify. What I need it to do is look at an ever changing log file and print the 3rd to last line. Is there a command that will display this? I can not use line numbers because the file is always growing. Thanks for any help (2 Replies)
Discussion started by: NivekRaz
2 Replies

2. Shell Programming and Scripting

Print line if first Field matches a pattern

Hi All, I would like my code to be able to print out the whole line if 1st field has a dot in the number. Sample input and expected output given below. My AWK code is below but it can;t work, can any expert help me ? Thanks in advance. {if ($1 ~ /*\.*/) { print $0 }} Input: ... (2 Replies)
Discussion started by: Raynon
2 Replies

3. Shell Programming and Scripting

only print line if 3rd field is 01

Similar question... I have a space delimited text file and I want to only print the lines where the 3rd word/field/column is equal to "01" awk '{if $3 = "01" print $0}' something like this. I meant to say: only print line IF 3rd field is 01 (2 Replies)
Discussion started by: ajp7701
2 Replies

4. UNIX for Dummies Questions & Answers

Match pattern in a field, print pattern only instead of the entire field

Hi ! I have a tab-delimited file, file.tab: Column1 Column2 Column3 aaaaaaaaaa bbtomatoesbbbbbb cccccccccc ddddddddd eeeeappleseeeeeeeee ffffffffffffff ggggggggg hhhhhhtomatoeshhh iiiiiiiiiiiiiiii ... (18 Replies)
Discussion started by: lucasvs
18 Replies

5. Shell Programming and Scripting

awk to compare 2nd and 3rd field and print the differences

need a one liner to compare 2nd and 3rd field and print values that are not matched in 2nd field Input col 2 col 3 1.1.1.1 11.11.11.11 8.8.8.8 0.0.0.0 3.3.3.3 2.2.2.2 7.7.7.7 3.3.3.3 5.5.5.5 1.1.1.1 4.4.4.4 6.6.6.6 9.9.9.9 output 7.7.7.7 ... (12 Replies)
Discussion started by: chidori
12 Replies

6. Shell Programming and Scripting

Insert certain field of matched pattern line above pattern

Hello every, I am stuck in a problem. I have file like this. I want to add the fifth field of the match pattern line above the lines starting with "# @D". The delimiter is "|" eg > # @D0.00016870300|0.05501020000|12876|12934|3||Qp||Pleistocene||"3 Qp Pleistocene"|Q # @P... (5 Replies)
Discussion started by: jyu3
5 Replies

7. Shell Programming and Scripting

UNIX help to print 50 lines after every 3rd occurrence pattern till end of file

I need help with extract/print lines till stop pattern. This needs to happen after every 3rd occurrence of start pattern and continue till end of file. Consider below is an example of the log file. my start pattern will be every 3rd occurrence of ERROR_FILE_NOT_FOUND and stop pattern will be... (5 Replies)
Discussion started by: NSS
5 Replies

8. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

9. Shell Programming and Scripting

Command/script to match a field and print the next field of each line in a file.

Hello, I have a text file in the below format: Source Destination State Lag Status CQA02W2K12pl:D:\CAQA ... (10 Replies)
Discussion started by: pocodot
10 Replies

10. Shell Programming and Scripting

Print field after pattern in all lines

data: hello--hello1--hello2--#growncars#vello--hello3--hello4--jello#growncars#dello--gello--gelloA--gelloB#growncars# I want to be able to print all the values that are found between the patterns "#growncars#" and the next "#growncars#" on the same line. so the output should be: ... (8 Replies)
Discussion started by: SkySmart
8 Replies
LDAPSEARCHPREFS.CONF(5) 					File Formats Manual					   LDAPSEARCHPREFS.CONF(5)

NAME
ldapsearchprefs.conf - configuration file for LDAP search preference routines SYNOPSIS
/etc/openldap/ldapsearchprefs.conf DESCRIPTION
The file /etc/openldap/ldapsearchprefs.conf contains information used by the LDAP search preference routines (see ldap-searchpref(3)). Blank lines and lines that have a first character of `#' are treated as comments and ignored. Non-comment lines contain one or more tokens. Tokens are separated by white space, and double quotes `"' can be used to include white space inside a token. Search preferences are typically used by LDAP-based client programs to specify what a user may search for, which attributes are searched, and which options are available to the user. The first non-commment line specifies the version of the template information and must contain the token Version followed by an integer version number. E.g., Version 1 The current version is 1, so the above example is always the correct opening line. The remainder of the file consists of one or more search preference configurations. The first line of a search preference is a human-read- able name for the type of object being searched for, e.g. "People" or "Organizations". This name is stored in the so_objtypeprompt member of the ldap_searchobj structure. E.g., "People" specifies a label for a search preference designed to find X.500 entries for People. The next line specifies a list of options for this search object. The only option currently allowed is "internal" which means that this search object should not be presented directly to a user. Options are placed in the so_options member of the ldap_searchobj structure and can be tested using the LDAP_IS_SEARCHOBJ_OPTION_SET() macro. Use "" if no special options are desired. The next line specifes a label to use for "Fewer Choices" (for lack of a better term) searches. "Fewer Choices" searches are those where the user's input is fed to the ldap_filter routines to determine an appropriate filter to use. This contrasts with explicitly-constructed LDAP filters, or "More Choices" searches, where the user can explicitly construct an LDAP filter. The "Fewer" and "More Choices" terms derive from the maX.500, waX.500 and xax500 directory user agents, which offer two configurations of their "Find Entry" dialogs - one where the user types a search string, and the client code attempts to find reasonable filter(s) to use in searching ("Fewer Choices"), and one where the user can select from several pop-up menus which allow complete specification of the search to be performed ("More Choices"). For example: "Search For:" can be used by LDAP client programs to label the field into which the user can type a "Fewer Choices" search. This information is stored in the so_prompt member of the ldap_searchobj structure. The next line specifies an LDAP filter prefix to append to all "More Choices" searched. This is typically used to limit the types of entries returned to those containing a specific object class. For example: "(&(objectClass=person)" would cause only entries containing the object class "person" to be returned by a search. Note that parentheses may be unbalanced here, since this is a filter prefix, not an entire filter. This information is stored in the so_filterprefix member of the ldap_searchobj struc- ture. The next line is an LDAP filter tag (see ldap-filter(3)) which specifies the set of LDAP filters to be applied for "Fewer Choices" search- ing. The line "xax500-People" would tell the client program to use the set of LDAP filters from the ldap filter configuration file tagged "xax500-People". This informa- tion is stored in the so_filtertag member of the ldap_searchobj structure. The next line specifies an LDAP attribute to retrieve to help the user choose when several entries match the search terms specified. For example: "title" specifies that if more than one entry matches the search criteria, the client program should retrieve the "title" attribute that and present that to the user to allow them to select the appropriate entry. The next line specifies a label for the above attribute, e.g. "Title:" The above information is stored in the so_defaultselectattr and so_defaultselecttext members of the ldap_searchobj structure. Note that these are defaults, and are intended to be overridden by the sa_selectattr and sa_selecttext fields of the ldap_searchattr data structure (see below). The next line specifies the scope of the LDAP search to be performed. Acceptable values are subtree, onelevel, and base. See ldap(3) for more information. The next section is a list of "More Choices" search options, terminated by a line containing only the string "END". Example: "Common Name" cn 11111 "" "" "Surname" sn 11111 "" "" "Business Phone" "telephoneNumber" 11101 "" "" END Each line represents one method of searching. In this example, there are three ways of searching - by Common Name, by Surname, and by Business Phone number. The first field is the text which should be displayed to user. The second field is the attribute which will be searched. The third field is a bitmap which specifies which of the match types (discussed below) are permitted for this search type. A "1" value in a given bit position indicates that a particular match type is valid, and a "0" indicates that is it not valid. The fourth and fifth fields are, respectively, the select attribute name (corresponding to the sa_selectattr field of the ldap_searchattr data struc- ture) and on-screen name for the select attribute (corresponding to the sa_selecttext field). These values are intended to override the so_defaultselectattr and so_defaultselecttext values, described above. If blank, the client software should use the default values above. The next section is a list of search match options, terminated by a a line containing only the string "END". Example: "exactly matches" "(%a=%v))" "approximately matches" "(%a~=%v))" "starts with" "(%a=%v*))" "ends with" "(%a=*%v))" "contains" "(%a=*%v*))" END In this example, there are five ways of refining the search. For each method, there is an LDAP filter suffix which is appended to the ldap filter thus far constructed. The routine ldap_build_filter() may be used to construct the whole filter. It substitutes the appropriate attribute for "%a" in the filter, and a value (generally, something the user types) for "%v". EXAMPLE
The following example illustrates one possible configuration of search preferences for "people". # Version number Version 1 # Name for this search object People # Label to place before text box user types in "Search For:" # Filter prefix to append to all "More Choices" searches "(&(objectClass=person)" # Tag to use for "Fewer Choices" searches - from ldapfilter.conf file "xax500-People" # If a search results in > 1 match, retrieve this attribute to help # user disambiguate the entries... multilineDescription # ...and label it with this string: "Description" # Search scope to use when searching subtree # Follows a list of "More Choices" search options. Format is: # Label, attribute, select-bitmap, extra attr display name, extra attr ldap name # If last two are null, "Fewer Choices" name/attributes used "Common Name" cn 11111 "" "" "Surname" sn 11111 "" "" "Business Phone" "telephoneNumber" 11101 "" "" "E-Mail Address" "mail" 11111 "" "" "Uniqname" "uid" 11111 "" "" END # Match types "exactly matches" "(%a=%v))" "approximately matches" "(%a~=%v))" "starts with" "(%a=%v*))" "ends with" "(%a=*%v))" "contains" "(%a=*%v*))" END In this example, the user may search for People. For "fewer choices" searching, the tag for the ldap filter config file is "xax500-Peo- ple". FILES
/etc/openldap/ldapsearchprefs.conf SEE ALSO
ldap(3). ldap-searchprefs(3) ACKNOWLEDGEMENTS
OpenLDAP is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). OpenLDAP is derived from University of Michigan LDAP 3.3 Release. OpenLDAP 2.0.27-Release 20 August 2000 LDAPSEARCHPREFS.CONF(5)
All times are GMT -4. The time now is 12:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy