Search for specific key in a file and print it


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Search for specific key in a file and print it
Prev   Next
# 4  
Old 07-20-2019
Try
Code:
awk '/Services/ {match ($0, /[A-Za-z_]*COB[A-Za-z_]*/); print substr ($0, RSTART, RLENGTH)}' file
NEPAL_COB

This User Gave Thanks to RudiC For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Scripting , need to search and print a line that contains a specific pattern

Take example of below file. abc.txt nas1:/abc/test/test1 /test nas1:/abc/test/test1/test2 /test/abc nas1:/abc/test/ Now i have a variable that contains "nas1:/abc/test/test1" value , so i need to search the above file for this variable and print only this line. ... (14 Replies)
Discussion started by: mohit_vardhani
14 Replies

2. UNIX for Beginners Questions & Answers

Non-root script used search and list specific key words

Hy there all. Im new here. Olso new to terminal & bash, but it seams that for me it's much easyer to undarsatnd scripts than an actual programming language as c or anyother languare for that matter. S-o here is one og my home works s-o to speak. Write a shell script which: -only works as a... (1 Reply)
Discussion started by: Crisso2Face
1 Replies

3. Shell Programming and Scripting

Search for a specific word and print only the word from the input file

Hi, I have a sample file as shown below, I am looking for sed or any command which prints the complete word only from the input file. Ex: $ cat "sample.log" I am searching for a word which is present in this file We can do a pattern search using grep but I need to cut only the word which... (1 Reply)
Discussion started by: mohan_kumarcs
1 Replies

4. UNIX for Dummies Questions & Answers

Search for a specific String in a log file for a specific date range

Hi, I have log file which rolls out every second which is as this. HttpGenRequest - -<!--OXi dbPublish--> <created="2014-03-24 23:45:37" lastMsgId="" requestTime="0.0333"> <response request="getOutcomeDetails" code="114" message="Request found no matching data" debug="" provider="undefined"/>... (3 Replies)
Discussion started by: karthikprakash
3 Replies

5. Shell Programming and Scripting

Search specific name in a file and fetch specific entries

Hi all, I have 2 files, One file contain data like this FHIT CS CHRM1 PDE3A PDE3B HSP90AA1 PTK2 HTR1A ESR1 PARP1 PLA2G1B These names are mentioned in the second file(Please see attached second file) as (7 Replies)
Discussion started by: manigrover
7 Replies

6. Shell Programming and Scripting

Urgent request to consider:Search specific name in a file and fetch specific entries

Hi all, I have 2 files, One file contain data like this FHIT CS CHRM1 PDE3A PDE3B HSP90AA1 PTK2 HTR1A ESR1 PARP1 PLA2G1B These names are mentioned in the second file(Please see attached second file) as # Drug_Target_X_Gene_Name:(Where X can be any number (1-1000) (1 Reply)
Discussion started by: manigrover
1 Replies

7. Shell Programming and Scripting

search-word-print-specific-string

Hi, Our input xml looks like: <doc> <str name="account_id">1111</str> <str name="prd_id">DHEP155EK</str> </doc> - <doc> <str name="account_id">6666</str> <str name="prd_id">394531662</str> </doc> - <doc> <str name="account_id">6666</str> <str... (1 Reply)
Discussion started by: Jassz
1 Replies

8. Shell Programming and Scripting

search a word and print specific string using awk

Hi, I have list of directory paths in a variable and i want to delete those dirs and if dir does not exist then search that string and get the correct path from xml file after that delete the correct directory. i tried to use grep and it prints the entire line from the search.once i get the entire... (7 Replies)
Discussion started by: dragon.1431
7 Replies

9. Shell Programming and Scripting

Search in specific position and print the whole line

I have two files abc.dat and sant.dat (Big file 60k rows) for every line's 1,4 of abc.dat need to seach if this is present on 28,4 of sant.dat every line. if its present the output needs to go to bde.dat Example: contents abc.dat aaaa bbbb cccc dddd contents sant.dat this is... (4 Replies)
Discussion started by: ssantoshss
4 Replies

10. Shell Programming and Scripting

Print lines with search string at specific position

Hi Folks, I have a file with all fields defined by byte position, but any field can be empty so I cannot print lines based on a search of specific columns. I need to print all lines of this file where the string of two characters at byte position 100-101 contains the number 27. Any ideas? ... (4 Replies)
Discussion started by: HealthyGuy
4 Replies
Login or Register to Ask a Question
ldaplist(1)							   User Commands						       ldaplist(1)

NAME
ldaplist - search and list naming information from an LDAP directory using the configured profile SYNOPSIS
/usr/bin/ldaplist [-dlv] [database [key]...] /usr/bin/ldaplist -h DESCRIPTION
The ldaplist utility searches for and lists the naming information from the LDAP directory service defined in the LDAP configuration files generated by ldapclient(1M) during the client initialization phase. The Solaris LDAP client must be set up in order to use this utility. The database is either a container name or a database name as defined in nsswitch.conf(4). A container is a non-leaf entry in the Directory Information Tree (DIT) that contains naming service information. The container name is the LDAP Relative Distinguished Name (RDN) of the container relative to the defaultSearchBase as defined in the configuration files. For example, for a container named ou=people, the data- base name is the database specified in nsswitch.conf. This database is mapped to a container, for example, passwd maps to ou=people. If an invalid database is specified, it will be mapped to a generic container, for example, nisMapName=name). The key is the attribute value to be searched in the database. You can specify more than one key to be searched in the same database. The key can be specified in either of two forms: attribute=value or value. In the first case, ldaplist passes the search key to the server. In the latter case, an attribute is assigned depending on how the database is specified. If the database is a container name, then the "cn" attribute type is used. If the database is a valid database name as defined in the nsswitch.conf, then a predefined attribute type is used (see table below). If the database is an invalid database name, then cn is used as the attribute type. The ldaplist utility relies on the Schema defined in the RFC 2307bis, currently an IETF draft. The data stored on the LDAP server must be stored based on this Schema, unless the profile contains schema mapping definitions. For more information on schema mapping see ldap- client(1M). The following table lists the default mapping from the database names to the container, the LDAP object class, and the attribute type used if not defined in the key. Database Object Class Attribute Type Container aliases mailGroup cn ou=Aliases automount nisObject cn automountMapName=auto_* bootparams bootableDevice cn ou=Ethers ethers ieee802Device cn ou=Ethers group posixgroup cn ou=Group hosts ipHost cn ou=Hosts ipnodes ipHost cn ou=Hosts netgroup ipNetgroup cn ou=Netgroup netmasks ipNetwork ipnetworknumber ou=Networks networks ipNetwork ipnetworknumber ou=Networks passwd posixAccount uid ou=People protocols ipProtocol cn ou=Protocols publickey nisKeyObject uidnumber ou=People cn ou=Hosts rpc oncRpc cn ou=Rpc services ipService cn ou=Services printers printerService printer-uri ou=printers auth_attr SolarisAuthAttr nameT ou=SolarisAuthAttr prof_attr SolarisProfAttr nameT ou=SolarisProfAttr exec_attr SolarisExecAttr nameT ou=SolarisProfAttr user_attr SolarisUserAttr uidT ou=people audit_user SolarisAuditUser uidT ou=people o For the automount database, auto_*, in the container column, represents auto_home, auto_direct, ... o For the publickey database, if the key starts with a digit, it will be interpreted as an uid number. If the key starts with a non- digit, it will be interpreted as a host name. The ldaplist utility supports substring search by using the wildcard "*" in the key. For example, "my*" will match any strings that starts with "my". In some shell environments, keys containing the wildcard may need to be quoted. If the key is not specified, all the containers in the current search baseDN will be listed. OPTIONS
The following options are supported: -d Lists the attributes for the specified database, rather than the entries. By default, the entries are listed. -h Lists the database mapping. -l Lists all the attributes for each entry matching the search criteria. By default, ldaplist lists only the Distinguished Name of the entries found. -v Sets verbose mode. The ldaplist utility will also print the filter used to search for the entry. The filter will be prefixed with "+++". EXAMPLES
Example 1: Listing All Entries in the Hosts Database example% ldaplist hosts Example 2: Listing All Entries in a Non-Standard Database ou=new example% ldaplist ou=new Example 3: Finding "user1" in the passwd Database example% ldaplist passwd user1 Example 4: Finding the Entry With Service Port of 4045 in the services Database example% ldaplist services ipServicePort=4045 Example 5: Finding All Users With Username Starting with new in the passwd Database example% ldaplist passwd 'new*' Example 6: Listing the Attributes for the hosts Database example% ldaplist -d hosts EXIT STATUS
The following exit values are returned: 0 Successfully matched some entries. 1 Successfully searched the table and no matches were found. 2 An error occurred. An error message is output. FILES
/var/ldap/ldap_client_file Files that contain the LDAP configuration of the client. Do not manually modify these files. Their content /var/ldap/ldap_client_cred is not guaranteed to be human readable. To update these files, use ldapclient(1M) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWnisu | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ SEE ALSO
ldap(1), ldapadd(1), ldapdelete(1), ldapmodify(1), ldapmodrdn(1), ldapsearch(1), idsconfig(1M), ldap_cachemgr(1M), ldapaddent(1M), ldap- client(1M), suninstall(1M), resolv.conf(4), attributes(5) NOTES
RFC 2307bis is an IETF informational document in draft stage that defines an approach for using LDAP as a naming service. SunOS 5.10 16 Jan 2004 ldaplist(1)