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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-22-2004, 10:14 AM
|
#1
|
Member
Registered: Aug 2003
Distribution: SuSE 9.0
Posts: 45
Rep:
|
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
|
|
|
09-22-2004, 10:26 AM
|
#2
|
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:
|
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
|
|
|
09-22-2004, 10:44 AM
|
#3
|
Member
Registered: Aug 2003
Distribution: SuSE 9.0
Posts: 45
Original Poster
Rep:
|
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
|
|
|
09-22-2004, 01:33 PM
|
#4
|
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:
|
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.
|
|
|
All times are GMT -5. The time now is 06:23 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|