Sponsored Content
Top Forums Shell Programming and Scripting Need to grep certain entry out of log file Post 302818475 by RudiC on Friday 7th of June 2013 03:07:41 PM
Old 06-07-2013
Please use codes tags as required by forum rules!

Try this:
Code:
sed -rn '/DIP-10219/ s/^.*[^,](cn=.*com).*$/\1/p' file | while read CMD; do echo ldapdelete -h \$OIDHOST -p \$OIDPORT -D \$OIDUSER -w \$OIDPWD -c -v dn \"$CMD\"; done
ldapdelete -h $OIDHOST -p $OIDPORT -D $OIDUSER -w $OIDPWD -c -v dn "cn=aala, steve (ora-ns),cn=users,dc=oracle,dc=com"
ldapdelete -h $OIDHOST -p $OIDPORT -D $OIDUSER -w $OIDPWD -c -v dn "cn=lui, john (ora),cn=users,dc=oracle,dc=com"

Once you're happy with what you see, you can remove the echo command and the escapes for the $signs. If your sed can't be made accept the extended regexes, you'll have to escape the parentheses in the substitute command.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep table entry problem

Hi, I have a table which looks like this Line a b c 0 10 0 0 1 0 0 2 0 ... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

2. UNIX for Dummies Questions & Answers

grep for password file entry

How would I grep for password file entry without using grep 'username' /etc/passwd? perhaps with who? I want to create alias that will find the password file entry regardless of the user who is using it. I am trying to get the same exact line from the file entry like: Name : Password : UserID... (7 Replies)
Discussion started by: alis
7 Replies

3. UNIX Desktop Questions & Answers

How to grep for password file entry

How would I grep for password file entry without using grep 'username' /etc/passwd? perhaps with who? I want to create alias that will find the password file entry regardless of the user who is using it. Thanks (4 Replies)
Discussion started by: alis
4 Replies

4. UNIX for Dummies Questions & Answers

grep first occurrence but continue to next entry in patternfile

I have 1300 files (SearchFiles0001.txt, SearchFiles0002.txt, etc.) , each with 650,000 lines, tab-delimited data. I have a pattern file, with about 1000 lines with a single word. Each single word is found in the 1300 files once. If I grep -f PatternFile.txt SearchFiles*.txt >OutputFile.txt... (2 Replies)
Discussion started by: newhavendweeb
2 Replies

5. Shell Programming and Scripting

How to write a new entry at the beginning of a log file instead of at the end?

Hi Ladies and Gents, Explanation of my question with an example: Let's consider the script: backup_every_hour.sh #!/bin/bash rsync -auv $dir $backup_dir >> backup_every_hour_script.log Each time this script is called there will be a new entry at the end of the file... (1 Reply)
Discussion started by: freddie50
1 Replies

6. Shell Programming and Scripting

[awk] grep a part of filename as entry file

hi all, i need to combine these files into one csv file. Bounce_Mail_Event_Daily_Report_01_Jul_2012.csv Bounce_Mail_Event_Daily_Report_02_Jul_2012.csv Bounce_Mail_Event_Daily_Report_03_Jul_2012.csv Bounce_Mail_Event_Daily_Report_04_Jul_2012.csv... (10 Replies)
Discussion started by: makan
10 Replies

7. Shell Programming and Scripting

How to grep a log file for words listed in separate text file?

Hello, I want to grep a log ("server.log") for words in a separate file ("white-list.txt") and generate a separate log file containing each line that uses a word from the "white-list.txt" file. Putting that in bullet points: Search through "server.log" for lines that contain any word... (15 Replies)
Discussion started by: nbsparks
15 Replies

8. UNIX for Dummies Questions & Answers

How to grep for first entry in a file?

Hello friends, I have a question. Sometimes I have to search for an entry in a file that is repeated thousands of times. Can you tell me how to search so that i get limited results? For example: file: myfile.txt grep "hello world" myfile.txt this above grep will generate 5000... (4 Replies)
Discussion started by: DallasT
4 Replies

9. Shell Programming and Scripting

Selecting latest entry in the log file

Hi there I am trying to write a script where I will need to look for a specific word in the log file and I am aware this can be done by grep for example. As there will be multiple entries for this I want to grep the last one to enter the log... how would I go about this - would I have to use... (5 Replies)
Discussion started by: simpsa27
5 Replies

10. Shell Programming and Scripting

Monitor and capture the latest entry from the log file

Hi, I want to monitor a log file using tail -f command and search for a specific string on the most recent entry from the file. If the search string matches with the most recent or last line from the file, I want send an email to the people with the message. tail -f service.log|tail -n 1 ... (5 Replies)
Discussion started by: svajhala
5 Replies
ldapdelete(1)							   User Commands						     ldapdelete(1)

NAME
ldapdelete - ldap delete entry tool SYNOPSIS
ldapdelete [-n] [-v] [-c] [-d debuglevel] [-f file] [-D bindDN] [-w passwd | -j file] [-J [:criticality]] [-?] [-H] [-h ldaphost] [-V version] [-i locale] [-k path] [-P path] [-N certificate] [-y proxyid] [-p ldapport] [-O hoplimit] [-o attributename=value] [-W pass- word] [dn...] DESCRIPTION
The ldapdelete utility opens a connection to an LDAP server, then binds and deletes one or more entries. If one or more dn arguments are provided, entries with those distinguished names are deleted. If no dn arguments are provided, a list of DNs is read from file, if the -f option is specified, or from standard input. OPTIONS
The following options are supported: -a Bypass confirmation question when deleting a branch. -c Continuous operation mode. Errors are reported, but ldapdelete will continue with deletions. The default is to exit after reporting an error. -d debuglevel Sets the LDAP debugging level. Useful levels of debugging for ldapdelete are: 1 Trace 2 Packets 4 Arguments 32 Filters 128 Access control To request more than one category of debugging information, add the masks. For example, to request trace and filter information, spec- ify a debuglevel of 33. -D bindDN Uses the distinguished name bindDN to bind to the directory. -E Ask server to expose (report) bind identity by means of authentication response control. -f file Reads the entry deletion information from file instead of from standard input. -? Display the usage help text that briefly describes all options. -H Display the usage help text that briefly describes all options. -h ldaphost Specifies an alternate host on which the LDAP server is running. -i locale Specify the character set to use for command-line input. The default is the character set specified in the LANG environment variable. You might want to use this option to perform the conversion from the specified character set to UTF8, thus overriding the LANG setting. Using this argument, you can input the bind DN and the target DNs in the specified character set. The ldapdelete tool converts the input from these arguments before it processes the search request. For example, -i no indicates that the bind DN and target DNs are provided in Norwegian. This option affects only the command-line input. That is, if you specify a file containing DNs (with the -f option), ldapdelete will not convert the data in the file. -j filename Specify a file containing the password for the bind DN or the password for the SSL client's key database. To protect the password, use this option in scripts and place the password in a secure file. This option is mutually exclusive of the -w and -W options. The -j option is the more secure alternative between -j and -w/-W. -J [:criticality[:value|::b64value|b64value|:fileurl]] Criticality is a boolean value (default is false). -k path Specify the path to a directory containing conversion routines. These routines are used if you want to specify a locale that is not supported by default by your directory server. This is for NLS support. -M Manage smart referrals. When they are the target of the operation, delete the actual entry containing the referral instead of the entry obtained by following the referral. -n Shows what would be done, but does not actually delete entries. Useful in conjunction with options -v and -d for debugging. -N certificate Specify the certificate name to use for certificate-based client authentication. For example: -N "Directory-Cert". -o attributename=value For SASL mechanisms and other options such as security properties, mode of operation, authorization ID, authentication ID, and so forth. The different attribute names and their values are as follows: secProp="number" For defining SASL security properties. realm="value" Specifies SASL realm (default is realm=none). authzid="value" Specify the authorization ID name for SASL bind. authid="value" Specify the authentication ID for SASL bind. mech="value" Specifies the various SASL mechanisms. -O hopLimit Specify the maximum number of referral hops to follow while finding an entry to delete. By default, there is no limit. -p ldapport Specifies an alternate TCP port where the LDAP server is listening. -P path Specify the path and filename of the client's certificate database. For example: -P /home/uid/.netscape/cert7.db When using the command on the same host as the directory server, you can use the server's own certificate database. For example: -P installDir/lapd-serverID/alias/cert7.db Use the -P option alone to specify server authentication only. -v Uses verbose mode, with diagnostics written to standard output. -V version Specify the LDAP protocol version number to be used for the delete operation, either 2 or 3. LDAP v3 is the default. Specify LDAP v2 when connecting to servers that do not support v3. -W password Specify the password for the client's key database given in the -P option. This option is required for certificate-based client authen- tication. Specifying password on the command line has security issues because the password can be seen by others on the system by means of the ps command. Use the -j instead to specify the password from the file. This option is mutually exclusive of -j. -w passwd Use passwd as the password for authentication to the directory. When you use -w passwd to specify the password to be used for authenti- cation, the password is visible to other users of the system by means of the ps command, in script files or in shell history. If you use the ldapdelete command without this option, the command will prompt for the password and read it from standard in. When used with- out the -w option, the password will not be visible to other users. -Y proxyid Specify the proxy DN (proxied authorization id) to use for the delete operation, usually in double quotes ("") for the shell. -Z Specify that SSL be used to provide certificate-based client authentication. This option requires the -N and SSL password and any other of the SSL options needed to identify the certificate and the key database. OPERANDS
The following operand is supported: dn Specifies one or several distinguished names of entries to delete. EXAMPLES
Example 1: Deleting an Entry To delete the entry named with commonName Delete Me directly below the XYZ Corporation organizational entry, use the following command: example% ldapdelete -D "cn=Administrator, o=XYZ, c=US" "cn=Delete Me, o=XYZ, c=US" Example 2: Deleting an Entry Using SASL Authentication To delete the entry named with commonName "Delete Me" directly below the XYZ Corporation organizational entry, use the following command: example% ldapdelete -o mech=DIGEST-MD5 -o secProp=noanonymous -o realm=none -o authid="dn:uid=foo,o=XYZ, c=US" "cn=Delete Me, o=XYZ, c=US" ATTRIBUTES
See attributes(5) for a description of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |Stability Level |Evolving | +-----------------------------+-----------------------------+ EXIT STATUS
The following exit values are returned: 0 Successful completion. Non-zero An error occurred. A diagnostic message is written to standard error. SEE ALSO
ldapadd(1), ldapmodify(1), ldapmodrdn(1), ldapsearch(1), ldap_get_option(3LDAP), ldap_set_option(3LDAP), attributes(5) NOTES
The -M authentication option is obsolete. SunOS 5.10 15 Jan 2004 ldapdelete(1)
All times are GMT -4. The time now is 08:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy