LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-22-2004, 09:14 AM   #1
mephitic
Member
 
Registered: Aug 2003
Distribution: SuSE 9.0
Posts: 45

Rep: Reputation: 15
Question Deleting data from file by date?


I've got a log file that I use for reporting purposes. Is it possible to run a command and delete data in file older then a certain date? It's starting to get a couple hundred megs and I'd like to remove any data older then say 2 months.

Is this possible? If so how do I go about doing this?

Thanks!
MePH
 
Old 09-22-2004, 09:26 AM   #2
Boudewijn
Member
 
Registered: Nov 2003
Location: The Netherlands
Distribution: MDK: 10,10.1,10_amd64,9.2,9.1 . Debian: sarge,woody, Gentoo (X86 amd64 Sparc)
Posts: 219

Rep: Reputation: 30
Hmm, I don't know exactly, but isn't it possible to write a script for doing that (it's possible :+ , I'm a programmer) . Something like:

-Determine current date minus 2 months
-Open file, and look for the date string
-Copy everything AFTER that string to a temporary file
-Delete the log
-Copy the temporary file back
 
Old 09-22-2004, 09:44 AM   #3
mephitic
Member
 
Registered: Aug 2003
Distribution: SuSE 9.0
Posts: 45

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Boudewijn
Hmm, I don't know exactly, but isn't it possible to write a script for doing that (it's possible :+ , I'm a programmer) . Something like:

-Determine current date minus 2 months
-Open file, and look for the date string
-Copy everything AFTER that string to a temporary file
-Delete the log
-Copy the temporary file back
Sounds like in theroy that would work. However I'm far beyond being able to program in Linux ... But if you have some free time and are willing to give it a shot, I'll be more then happy to work with you on it.

Thanks,
MePH
 
Old 09-22-2004, 12:33 PM   #4
Boudewijn
Member
 
Registered: Nov 2003
Location: The Netherlands
Distribution: MDK: 10,10.1,10_amd64,9.2,9.1 . Debian: sarge,woody, Gentoo (X86 amd64 Sparc)
Posts: 219

Rep: Reputation: 30
Ok,

seems cool to me.
Please add my jabber: boudewijnLinux@jabber.org
or

boudewijnector@hotmail.com (MSN)

We'll do it using a bash script i'd think, and post the code here.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I stop rsync from deleting data if network link is dropped? skyfly Linux - Networking 2 06-30-2004 10:35 AM
Deleting Linux, All Partitions, Every Shred of Data! g-force Linux - Newbie 2 05-03-2004 10:04 PM
Script for deleting files based on date MaverickApollo Linux - General 3 02-03-2004 07:54 PM
loading data from a flat file with a date and time having a different format spyghost Programming 2 11-02-2003 04:40 PM
deleting data from ppp network control patrickfreen Red Hat 2 10-13-2003 10:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration