Sponsored Content
Top Forums Shell Programming and Scripting Need to grep certain entry out of log file Post 302818447 by exm on Friday 7th of June 2013 02:23:28 PM
Old 06-07-2013
Need to grep certain entry out of log file

This one is a bit too challenging for me... Hopefully you guys can help.

Let's say I have a log file called:
"$MW_HOME/user_projects/domains/IDMDomain/servers/wls_ods?/logs/wls_ods1-diagnostic.log"

In this log file I want to search for "DIP-10219". When I execute this
Code:
$ cat $MW_HOME/user_projects/domains/IDMDomain/servers/wls_ods?/logs/wls_ods1-diagnostic.log  | grep DIP-10219

I get this output.
Code:
[2013-06-07T11:06:08.071-04:00] [wls_ods1] [ERROR] [DIP-10219] [oracle.dip.ORA_EBSAD] [tid: oracle.ldap.odip.web.DIPSyncWriterThread] [userId: <anonymous>] [ecid: 0000JwQp2v533Fw5GFP5if1HgDcU000002,1:26283] [APP: DIP#11.1.1.2.0] Exception creating entry : cn=aala\, steve (ora-ns),cn=users,dc=oracle,dc=com.
[2013-06-07T11:06:08.691-04:00] [wls_ods1] [ERROR] [DIP-10219] [oracle.dip.ORA_EBSAD] [tid: oracle.ldap.odip.web.DIPSyncWriterThread] [userId: <anonymous>] [ecid: 0000JwQp2v533Fw5GFP5if1HgDcU000002,1:26283] [APP: DIP#11.1.1.2.0] Exception creating entry : cn=lui\, john (ora),cn=users,dc=oracle,dc=com.

Based on this output, I need to write a wrapper that executes something with the output in red above.
Code:
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"

So I would like to know, how to:
1. Create a loop to search through the logfile
2. Pass the entries to a second command (ldapdelete), remove everything before "cn=" and after "=com"

Hopefully you can help me!

Last edited by exm; 06-07-2013 at 05:51 PM..
 

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
UNBUFFER(1)						      General Commands Manual						       UNBUFFER(1)

NAME
unbuffer - unbuffer output SYNOPSIS
unbuffer program [ args ] INTRODUCTION
unbuffer disables the output buffering that occurs when program output is redirected from non-interactive programs. For example, suppose you are watching the output from a fifo by running it through od and then more. od -c /tmp/fifo | more You will not see anything until a full page of output has been produced. You can disable this automatic buffering as follows: unbuffer od -c /tmp/fifo | more Normally, unbuffer does not read from stdin. This simplifies use of unbuffer in some situations. To use unbuffer in a pipeline, use the -p flag. Example: process1 | unbuffer -p process2 | process3 CAVEATS
unbuffer -p may appear to work incorrectly if a process feeding input to unbuffer exits. Consider: process1 | unbuffer -p process2 | process3 If process1 exits, process2 may not yet have finished. It is impossible for unbuffer to know long to wait for process2 and process2 may not ever finish, for example, if it is a filter. For expediency, unbuffer simply exits when it encounters an EOF from either its input or process2. In order to have a version of unbuffer that worked in all situations, an oracle would be necessary. If you want an application-specific solution, workarounds or hand-coded Expect may be more suitable. For example, the following example shows how to allow grep to finish pro- cessing when the cat before it finishes first. Using cat to feed grep would never require unbuffer in real life. It is merely a place- holder for some imaginary process that may or may not finish. Similarly, the final cat at the end of the pipeline is also a placeholder for another process. $ cat /tmp/abcdef.log | grep abc | cat abcdef xxxabc defxxx $ cat /tmp/abcdef.log | unbuffer grep abc | cat $ (cat /tmp/abcdef.log ; sleep 1) | unbuffer grep abc | cat abcdef xxxabc defxxx $ BUGS
The man page is longer than the program. SEE ALSO
"Exploring Expect: A Tcl-Based Toolkit for Automating Interactive Programs" by Don Libes, O'Reilly and Associates, January 1995. AUTHOR
Don Libes, National Institute of Standards and Technology 1 June 1994 UNBUFFER(1)
All times are GMT -4. The time now is 07:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy