Sponsored Content
Top Forums Shell Programming and Scripting Delete lines prior to a specific date in a log file. Post 302304242 by ahSher on Sunday 5th of April 2009 11:30:20 PM
Old 04-06-2009
Delete lines prior to a specific date in a log file.

Hi all.

I have a database log file in which log data get appended to it daily. I want to do a automatic maintainence of this log by going through the log and deleting lines belonging to a certain date.

How should i do it? Please help. Thanks.

Example. To delete all lines prior to Jun 3.

My content of my log is like below:
Sun Jun 1 01:38:25 2008
Completed: ALTER DATABASE OPEN
Sun Jun 1 22:00:40 2008
Thread 1 advanced to log sequence 2518
Current log# 1 seq# 2518 mem# 0: /u03/oradata/sbdevdb/redo01.log
Current log# 1 seq# 2518 mem# 1: /u03/oradata/sbdevdb/redo04.log
Mon Jun 2 10:00:33 2008
Thread 1 advanced to log sequence 2519
Current log# 2 seq# 2519 mem# 0: /u04/oradata/sbdevdb/redo02.log
Current log# 2 seq# 2519 mem# 1: /u04/oradata/sbdevdb/redo05.log
Mon Jun 2 22:01:10 2008
Thread 1 advanced to log sequence 2520
Current log# 3 seq# 2520 mem# 0: /u05/oradata/sbdevdb/redo03.log
Current log# 3 seq# 2520 mem# 1: /u05/oradata/sbdevdb/redo06.log
Tue Jun 3 01:30:03 2008
Starting background process EMN0
EMN0 started with pid=20, OS id=639158
Tue Jun 3 01:30:03 2008
Shutting down instance: further logons disabled
Tue Jun 3 01:30:03 2008


 

10 More Discussions You Might Find Interesting

1. Programming

Delete specific lines in a text file

Hi, experts, I would like to create a function that can calculate the total number of lines in a saved text file and delete specific lines in that particular file (I only want the last few lines). Hav anybody have the experience and giv me a hand in this? (9 Replies)
Discussion started by: dniz
9 Replies

2. Shell Programming and Scripting

Delete specific lines from a file

Hi, I have a file ( all_users.ldif ) of the following format: cn=orcladmin, cn=Users, dc=maximus,dc=com cn=PUBLIC, cn=Users, dc=maximus,dc=com cn=portal,cn=users,dc=maximus,dc=com cn=portal_admin,cn=users,dc=maximus,dc=com cn=uddi_publisher,cn=Users,dc=maximus,dc=com... (4 Replies)
Discussion started by: itzz.me
4 Replies

3. Shell Programming and Scripting

how to delete lines from a file which starts with a specific pattern

I need to delete those lines from a file, which starts with 45. How to do it? (3 Replies)
Discussion started by: mady135
3 Replies

4. Shell Programming and Scripting

Delete lines in a file by date on the line

Hi I have a file with lines ending with a date in format dd/mm/yyyy see example below: a|b|c|08/01/2011 d|a|e|31/11/2010 e|d|f|20/11/2010 f|s|r|18/01/2011 What I would like to do is delete all lines with a date older than 30 days. With above example I should be left with a file... (5 Replies)
Discussion started by: fas1
5 Replies

5. Shell Programming and Scripting

Delete file with specific date

let say i have list of file PermissionsDirectoriesGroupSizeDateDirectory or file drwx------2users4096Nov 2 19:51mailv drwxr-s---35www 32768Jan 20 22:39public_htmlt drwx------ 2 users 4096 Nov 2 19:51 mail drwxr-s--- 35 www 32768 Jan 20 22:39 public_html drwxr-s--- 35 www 32768 Jan... (3 Replies)
Discussion started by: Jewel
3 Replies

6. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

7. UNIX for Dummies Questions & Answers

How to delete specific lines (2n+3 line, n=0,1,2...296) in a file?

Dear everyone, I have a file with 900 lines (there is only numbers in one line, no string), I only need the lines 2+3n (n=0,1...296), i.e line 2, 5, 8, 11...888. I tried google but only the results such as how to delete all the odd lines or all the even lines with 'awk' command. Thanks in... (4 Replies)
Discussion started by: phamnu
4 Replies

8. Shell Programming and Scripting

Grep all lines for a specific date in log-files

I need to grep all lines for "yesterday" in /var/log/messages. Dates are in the format "YYYY-MM-DD". (5 Replies)
Discussion started by: Padmanabhan
5 Replies

9. Shell Programming and Scripting

Delete specific lines from files based on another file

I have some text files in a folder named ff as follows. I need to delete the lines (in-place editing)in these files based on another file aa.txt. 32bm.txt: 249 253 A P - 0 0 8 0, 0.0 6,-1.4 0, 0.0 2,-0.4 -0.287 25.6-102.0 -74.4 161.1 37.1 13.3 10.9 250... (2 Replies)
Discussion started by: aden
2 Replies

10. 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
petitboot-nc(8) 					    BSD System Manager's Manual 					   petitboot-nc(8)

NAME
petitboot-nc -- Petitboot ncurses bootloader UI SYNOPSIS
petitboot-nc [-d, --start-daemon] [-h, --help] [-l, --log log-file] [-V, --version] DESCRIPTION
petitboot-nc is an ncurses based interface to the Petitboot bootloader. Petitboot is a Linux kexec based bootloader that supports loading Linux kernel and initrd images from any device that can be mounted by Linux. It can also load images from the network using the HTTP, HTTPS, NFS, SFTP, and TFTP protocols. OPTIONS
-d, --start-daemon Start pb-discover, the petitboot dynamic device discovery daemon, if it has not been started. This option is mainly useful when run- ning petitboot as a stand-alone application. -h, --help Print a help message. -l, --log log-file Log messages to the file log-file. The default log is a file /var/log/petitboot-nc.log. New messages are appended to an existing log file. -V, --version Display the program version number. SEE ALSO
petitboot(8), petitboot-twin(8), pb-discover(8), pb-event(8) REPORTING BUGS
Send bug reports to Geoff Levand <geoff @ infradead.org> BSD
June 1, 2019 BSD
All times are GMT -4. The time now is 09:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy