Sponsored Content
Top Forums Shell Programming and Scripting awk for presence of characters in a field Post 302358481 by Scott on Friday 2nd of October 2009 05:02:44 PM
Old 10-02-2009
Based on your input, I created a file (file1):

Code:
"10","server","","11111",JLB,
"10","server","A","11111",JLB,
"10","server","B","11111",JLB,

After the script runs, I have file1_0 and file1_1 with:
Code:
"10","server","B","11111",JLB,

Code:
"10","server","B","11111",JLB,

respectively.

Seeing Jim's "> 2" makes me think "keep it simple"! (and Solaris? was my next question)

Last edited by Scott; 10-02-2009 at 06:40 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies

2. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

3. UNIX for Dummies Questions & Answers

awk if one field has more characters than another

Hi all, I've been stuck on how to write a command in awk that looks at two columns and only prints entries where one of the columns has more than or less than a 3 character difference. I need to be able to compare any two columns preferably, but as an example, comparing columns 3 and 4 example... (9 Replies)
Discussion started by: torchij
9 Replies

4. Shell Programming and Scripting

awk repeat one field at all lines and modify field repetitions

Hello experts I have a file with paragraphs begining with a keeping date and ending with "END": 20120301 num num John num num A keepnum1 num num kathrin num num A keepnum1 num num kathrin num num B keepnum2 num num Pete num num A keepnum1 num num Jacob num... (2 Replies)
Discussion started by: phaethon
2 Replies

5. Shell Programming and Scripting

awk to parse field and include the text of 1 pipe in field 4

I am trying to parse the input in awk to include the |gc= in $4 but am not able to. The below is close: awk so far: awk '{sub(/\|]+]++/, ""); print }' input.txt Input chr1 955543 955763 AGRN-6|pr=2|gc=75 0 + chr1 957571 957852 AGRN-7|pr=3|gc=61.2 0 + chr1 970621 ... (7 Replies)
Discussion started by: cmccabe
7 Replies

6. Shell Programming and Scripting

How can awk ignore the field delimiter like comma inside a field?

We have a csv file as mentioned below and the requirement is to change the date format in file as mentioned below. Current file (file.csv) ---------------------- empname,date_of_join,dept,date_of_resignation ram,08/09/2015,sales,21/06/2016 "akash,sahu",08/10/2015,IT,21/07/2016 ... (6 Replies)
Discussion started by: gopal.biswal
6 Replies

7. Shell Programming and Scripting

awk to adjust coordinates in field based on sequential numbers in another field

I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines. If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
Discussion started by: cmccabe
3 Replies

8. Shell Programming and Scripting

awk to update field using matching value in file1 and substring in field in file2

In the awk below I am trying to set/update the value of $14 in file2 in bold, using the matching NM_ in $12 or $9 in file2 with the NM_ in $2 of file1. The lengths of $9 and $12 can be variable but what is consistent is the start pattern will always be NM_ and the end pattern is always ;... (2 Replies)
Discussion started by: cmccabe
2 Replies

9. Shell Programming and Scripting

Using awk to add length of matching characters between field in file

The awk below produces the current output, which will add +1 to $3. However, I am trying to add the length of the matching characters between $5 and $6 to $3. I have tried using sub as a variable to store the length but am not able to do so correctly. I added comments to each line and the... (4 Replies)
Discussion started by: cmccabe
4 Replies

10. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies
ldapsearchprefs.conf(4) 					   File Formats 					   ldapsearchprefs.conf(4)

NAME
ldapsearchprefs.conf - configuration file for LDAP search preference routines SYNOPSIS
/etc/opt/SUNWconn/ldap/current/ldapsearchprefs.conf DESCRIPTION
The ldapsearchprefs.conf file contains information used by LDAP when searching the directory. Blank lines and lines that start with a hash ('#') character 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. For example: 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, for example People or Organizations. This name is stored in the so_objtypeprompt mem- ber of the ldap_searchobj structure (see ldap_searchprefs(3LDAP)). For example: 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 required. The next line specifes a label to use for "Fewer Choices" 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. 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. 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. The next line is an LDAP filter tag which specifies the set of LDAP filters to be applied for "Fewer Choices" searching. The line "x500-People" would tell the client program to use the set of LDAP filters from the ldap filter configuration file tagged "x500-People". 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, for example, "Title:" Note that the values defined so far in the file are defaults, and are intended to be overridden by the specific search options that follow. The next line specifies the scope of the LDAP search to be performed. Acceptable values are subtree, onelevel, and base. The next section is a list of "More Choices" search options, terminated by a line containing only the string END. For 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 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 and on-screen name for the selected attribute. These values are intended to override the defaults defined above. If no specific values are specified, the client software uses 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. EXAMPLES
Example 1: A Sample Configuration Using Search Preference for "people" 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 "x500-People" # If a search results in > 1 match, retrieve this attribute to help # user distinguish between 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 ldapfilter.conf(4) file is "x500-People". ATTRIBUTES
See attributes(5) for a description of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWlldap | +-----------------------------+-----------------------------+ |Stability Level |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
ldap_searchprefs(3LDAP) , attributes(5) SunOS 5.10 9 Jul 2003 ldapsearchprefs.conf(4)
All times are GMT -4. The time now is 01:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy