Sponsored Content
Top Forums Shell Programming and Scripting Copy subsequent contents of a file from first occurance of grep Post 302294283 by sunpraveen on Thursday 5th of March 2009 01:01:02 AM
Old 03-05-2009
@Shawn, I can not grep the date command lines because errors and alerts in the alert log are written below the line which contains the date. Below is the sample alert log file.

Now, anything that has "ORA-" is usually an error and I want to capture that for today's date. Hence, I need to copy the subsequent contents of today's date's first occurance.

Suppose today is Mar 4 2009, then when the first occurance of the line occurs, I would like to copy the contents of the alert log from the first occurance line to the end to a temporary file and then search for any errors in that temporary file.

Code:
Tue Mar  3 22:23:37 2009
Completed checkpoint up to RBA [0x39a7.2.10], SCN: 10372821759272
Tue Mar  3 22:34:40 2009
Incremental checkpoint up to RBA [0x39a7.29021.0], current log tail at RBA [0x39a7.38f7e.0]
Tue Mar  3 22:54:44 2009
Incremental checkpoint up to RBA [0x39a7.7c0bc.0], current log tail at RBA [0x39a7.7edfc.0]
Tue Mar  3 23:14:48 2009
Incremental checkpoint up to RBA [0x39a7.acb35.0], current log tail at RBA [0x39a7.b72f6.0]
Tue Mar  3 23:34:52 2009
Incremental checkpoint up to RBA [0x39a7.f4f6f.0], current log tail at RBA [0x39a7.fb55a.0]
Tue Mar  3 23:54:57 2009
Incremental checkpoint up to RBA [0x39a7.12598f.0], current log tail at RBA [0x39a7.1371ec.0]
Wed Mar  4 00:10:16 2009
ORA-00060: Deadlock detected. More info in file /opt/dbms/app/oracle/product/comtst/10.2.0/admin/COMTST_suomt05k/udump/comtst_ora_25663.trc.
Wed Mar  4 00:10:22 2009
ORA-00060: Deadlock detected. More info in file /opt/dbms/app/oracle/product/comtst/10.2.0/admin/COMTST_suomt05k/udump/comtst_ora_5983.trc.
Wed Mar  4 00:15:02 2009
Incremental checkpoint up to RBA [0x39a7.15fff7.0], current log tail at RBA [0x39a7.160c26.0]
Wed Mar  4 00:35:06 2009
Incremental checkpoint up to RBA [0x39a7.191204.0], current log tail at RBA [0x39a7.1a5c0c.0]
Wed Mar  4 00:55:10 2009
Incremental checkpoint up to RBA [0x39a7.1b67bb.0], current log tail at RBA [0x39a7.1b75a1.0]
Wed Mar  4 01:15:14 2009
Incremental checkpoint up to RBA [0x39a7.1c96f7.0], current log tail at RBA [0x39a7.1ca1ef.0]
Wed Mar  4 01:35:18 2009
Incremental checkpoint up to RBA [0x39a7.1cd31a.0], current log tail at RBA [0x39a7.1d1b92.0]
Wed Mar  4 01:38:03 2009
Beginning log switch checkpoint up to RBA [0x39a8.2.10], SCN: 10372886671282
Thread 1 advanced to log sequence 14760
  Current log# 8 seq# 14760 mem# 0: /opt/apps/comsdb/comtstdata/redo08a.log
  Current log# 8 seq# 14760 mem# 1: /opt/apps/comsdb/comtstdata/redo08b.log
Wed Mar  4 01:43:07 2009
Completed checkpoint up to RBA [0x39a8.2.10], SCN: 10372886671282
Wed Mar  4 01:55:25 2009
Incremental checkpoint up to RBA [0x39a8.1429a.0], current log tail at RBA [0x39a8.14980.0]
Wed Mar  4 02:15:30 2009
Incremental checkpoint up to RBA [0x39a8.24b0f.0], current log tail at RBA [0x39a8.255d4.0]
Wed Mar  4 02:35:34 2009
Incremental checkpoint up to RBA [0x39a8.280fe.0], current log tail at RBA [0x39a8.28d8a.0]
Wed Mar  4 02:55:38 2009
Incremental checkpoint up to RBA [0x39a8.4e2aa.0], current log tail at RBA [0x39a8.5200a.0]
Wed Mar  4 03:15:42 2009
Incremental checkpoint up to RBA [0x39a8.6231a.0], current log tail at RBA [0x39a8.6306b.0]

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy selected contents from file

I want to capture contents of a file between 2 strings into another file for eg all lines in between the keywords "start log" and "end log" should be copied into another file (4 Replies)
Discussion started by: misenkiser
4 Replies

2. Shell Programming and Scripting

Automatic Copy of File Contents to Clipboard

Could someone show me how to copy the contents of a file to the clipboard automatically without manually selecting its contents? I just want to press the "Paste Key" to show the results. I wish to use this in a ksh script. I'm using Solaris. Thanks! (5 Replies)
Discussion started by: ilak1008
5 Replies

3. Shell Programming and Scripting

How to insert values in 1st occurance out of two occurance in a file

Hi I have a file which contains the following two lines which are same But I would like to insert the value=8.8.8.8 in the 1st occurance line and value=9.9.9.9 in the 2nd occurance line. <parameter name="TestIp1" value=""> <parameter name="TestIp1" value=""> Please suggest (1 Reply)
Discussion started by: madhusmita
1 Replies

4. Shell Programming and Scripting

copy the contents between two keywords to a new file.

Hi All, I want to edit my gate level netlists by searching for the content between two patterns eg: ff1 \test/a0 ( .CLK(\test/ClkInt0_acb_00x1 ),.D(\test/Rakicc ), .QB(\test/X ), .VDD(1'b1), .VSS(1'b0)); ff1 \test/a1 ( .CLK(\test/medis0_acb_00x1 ),.D(\test/hedwc ), .QB(\test/X ),... (6 Replies)
Discussion started by: naveen@
6 Replies

5. Shell Programming and Scripting

Grep and fetch subsequent lines also

Hi, I need to grep a pattern and fetch subsequent lines till end of the data-set. E.g., i have a file like: AA 1111 23 34 BB 45 56 78 CC 22 44 AA 2222 78 34 56 BB 22 56 67 68 23 CC 56 78 DD 33 55 77 AA 3333 46 BB 58 79 In above file i have 3-data sets where each set starts with... (6 Replies)
Discussion started by: prvnrk
6 Replies

6. UNIX for Dummies Questions & Answers

Copy entire contents of file to clipboard

Hi, I am trying to figure out how to copy the contents of a file to the clipboard, then paste into a command. i.e copy contents of file /path/filename.txt to <command> <paste text> Hope that makes sense. Basically tryting to copy the text for use in a command without having to open the... (8 Replies)
Discussion started by: JCA70
8 Replies

7. Shell Programming and Scripting

Need help to copy contents of a file

Hi, I am stuck up with a problem of copying the contents of a directory where one of the folder name is changed daily. Problem: I have the folder structure as: RefWorlds2/LINGCC4_X64/odsdev/odessy/UTI/621GA_build_xxx/.../.. In the above path the build number (xxx) will be changed... (3 Replies)
Discussion started by: SathaKarni
3 Replies

8. Shell Programming and Scripting

Need Script to copy the contents of two files into one file

Hi i need Script to copy the contents of two files into one file i have 2 fil X1.txt / X2.txt i need script to copy the contents of X1 and X2 In AllXfile X1.txt File X1 X2.txt File X2 AllXfile.txt File X1 File X2 (2 Replies)
Discussion started by: azzeddine2005
2 Replies

9. Shell Programming and Scripting

Copy contents of one file to another

I need to write a script (in bash) that copies the content of the first file in each folder of a directory to the second file in the same folder. I tried this and it didn't work - it just came back with errors and I'm not sure how to fix it. Help is very much appreciated! for mpdir in... (4 Replies)
Discussion started by: LeftoverStew
4 Replies

10. UNIX for Beginners Questions & Answers

Copy last 30 minutes' contents from a log file

Hi Guys, I am writing a bash script to capture the last 30 minutes's contents from log file to a new file. This job is a scheduled job and will run every 30 minutes. The log file is db2diag.log in DB2. I am having difficulties copying the last 30 minutes's contents. Can someone please help me.... (4 Replies)
Discussion started by: naveed
4 Replies
sealert(8)																sealert(8)

NAME
sealert - setroubleshoot client tool SYNOPSIS
sealert [-b] [-f local_id] [-h] [-s] [-S] [-l id] [-a file] [-u] [-p] [-P plugin_name] DESCRIPTION
This manual page describes the sealert program. sealert is the user interface component (either GUI or command line) to the setroubleshoot system. setroubleshoot is used to diagnose SELinux denials and attempts to provide user friendly explanations for a SELinux denial (e.g. AVC) and recommendations for how one might adjust the system to prevent the denial in the future. In a standard configuration setroubleshoot is composed of two components, setroubleshootd and sealert. setroubleshootd is a system daemon which runs with root privileges and listens for audit events emitted from the kernel related to SELinux. The audit daemon must be running. The audit daemon sends a dbus message to the setroubleshootd daemon when the system gets an SELinux AVC denial. The setroubleshootd daemon then runs a series of analysis plugins which examines the audit data related to the AVC. It records the results of the analysis and signals any clients which have attached to the setroubleshootd daemon that a new alert has been seen. sealert can be run in either a GUI mode or a command line mode. In both instances sealert run as a user process with the privileges associ- ated with the user. In GUI mode it attaches to a setroubleshootd server instance and listens for notifications of new alerts. When a new alert arrives it alerts the desktop user via a notification in the status icon area. The user may then click on the alert notification which will open an alert browser. In addition to the current alert sealert communicates with the setroubleshootd daemon to access all prior alerts stored in the setroubleshoot database. The user may elect to tag any given alert as "ignore" in the browser which prevents any future notification for the given alert. This is useful when a user is already aware of a reoccurring problem. sealert may also be run in command line mode. The two most useful command line options are -l to "lookup" an alert ID and -a to "analyze" a log file. When setroubleshootd generates a new alert it assigns it a local ID and writes this as a syslog message. The -l lookup option may then be used to retrieve the alert from the setroubleshootd alert database and write it to stdout. This is most useful when setroubleshootd is being run on a headless system without the GUI desktop alert facility. The -a analyze option is equivalent to the "Scan Logfile" command in the browser. The log file is scanned for audit messages, analysis is performed, alerts generated, and then written to stdout. LOG FILE SCANNING
You may ask sealert to parse a file accumulating all the audit messages it finds in that file. As each audit event is recognized it is pre- sented for analysis which may generate an alert report if the analysis was successful. If the same type of event is seen multiple times resulting in the same report the results are coalesced into a single report. The report count field will indicate the number of times the tool thought it saw the same issue. The report will also include a list of every line number on which it found an audit record which con- tributed to the coalesced report. This will allow you to coordinate the contents of the file with the analysis results if need be. Log file scanning may be initiated from the sealert browser via the File::ScanLogFile menu or from the command line via 'sealert -a file- name'. Please note that sealert runs as a user level process with the permissions of the user running it. Many system log files are read- able by root only. To work around this if you have root access one can copy the file as root to a temporary file and change its permis- sions. This is a good solution when scanning via the GUI as a normal user. Or you might consider su'ing to root and run the analysis via the command line (e.g. sealert -a filename). The audit records in the log file must be valid syntactically correct audit messages or the parser will ignore them. OPTIONS
-b --browser Launch the browser -f --fix Execute the fix command for the avc with the given uuid and plugin, requires --plugin option. -h --help Show this message -s --service Start sealert service, Usually used by dbus. -S --noservice Start sealert without dbus service as stand alone app -l --lookupid id Lookup alert by id, if id is wildcard * then return all alerts -a --analyze file Scan a log file, analyze its AVC's -u --user logon as user -p --password set user password -P --plugin Set plugin name associated with the --fix option AUTHOR
This man page was written by John Dennis <jdennis@redhat.com> and Dan Walsh <dwalsh@redhat.com>. SEE ALSO
selinux(8), 20061121 sealert(8)
All times are GMT -4. The time now is 01:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy