Sponsored Content
Top Forums Shell Programming and Scripting Remove lines older than 30 days Post 302883832 by Klashxx on Thursday 16th of January 2014 09:00:30 AM
Old 01-16-2014
A python:
Code:
#!/usr/bin/env python

import sys
from time import mktime,strptime 
from datetime import datetime

now  = datetime.now()
with open('sample.txt','rb') as f:
    for line in f:
        L = line.split('|')
        before = datetime.fromtimestamp(
                 mktime(strptime(L[0],'%d-%m-%Y %I:%M:%S %p')))
        old = now - before
        if  old.days < 30:
            sys.stdout.write(line)

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find files older than 5 days and remove tem after listing

need help with this ... Find files older than 5 days and remove tem after listing list "test" file older than 5 days and then remove them (1 Reply)
Discussion started by: ypatel6871
1 Replies

2. Shell Programming and Scripting

Need to remove files older than 30 days except directories

Hi, I need to remove files (*.trc) which are older than 30 days from one location. My problem is there I do not want to visit any of the directories at that location. I want to search files at that particular location only (need to skip directorys at that location). maxdepth option is there... (6 Replies)
Discussion started by: malaymaru
6 Replies

3. Shell Programming and Scripting

How to tar, compress and remove files older than two days

Hi, I'm Eddy from Belgium and I've the following problem. I try to write a ksh script in AIX to tar, compress and remove the original *.wav files from the directory belgacom_sf_messages older than two days with the following commands. The problem is that I do not find a good combination... (4 Replies)
Discussion started by: edr
4 Replies

4. Shell Programming and Scripting

script to remove files older than 60 days

Hi I need help in the script which looks at a contorl file which has a list of file names like xxxx.12345 and I want to take only xxxxx and search in a specific directory and remove the file if its older than 60 days I have written something like this.. but seems to be wrong... (1 Reply)
Discussion started by: antointoronto
1 Replies

5. UNIX for Advanced & Expert Users

How to Remove 180 days older non-empty directories

Hi Gurus, I have command to delete more than 180days file. find /home/abc/ -name "CBST_*.txt*" -mtime +180 | xargs -n 100 rm -f Now I would like to delete more than 180days Non empty directory--What will be command? Following is non empty directory as instance CBST2010* (2 Replies)
Discussion started by: thepurple
2 Replies

6. Shell Programming and Scripting

[Solved] Remove file older than 90 days

I have crontab job a tar file to a directory ( tar -cvf /tmp/backup/or.`date +%m%d%y`. /ora/db/* ) , it will do it every day . Now I don't want to keep too much files , I just want to keep the file for 90 days , can advise if I want to remove the backup file which are elder than 90 days , can... (1 Reply)
Discussion started by: ust3
1 Replies

7. Shell Programming and Scripting

Remove files older than 2 days.

Hi All, I am new to the scripting and using solaris 10 OS. Please suggest me from the below script which modifications need to be done to delete the files more that 2days older. Current script is deleting existing file. # Remove old explorer runs if needed DIR=`dirname ${EXP_TARGET}` if ... (2 Replies)
Discussion started by: Navkreddy
2 Replies

8. Shell Programming and Scripting

Search 2 days older file and then delete last 10 lines

I want to search 2 day older file and then delete last 10 line of that file. (2 Replies)
Discussion started by: sonu pandey
2 Replies

9. Shell Programming and Scripting

Shellscript command to remove files starting with a certain string, and older than 3 days

Hi All, Need help in identifying a shellscript command to remove all files on a server directory, starting with a certain prefix and also older than 3 days. That means files created with that prefix, today or yesterday, shouldn't be removed. Thanks, Dev (3 Replies)
Discussion started by: dev.devil.1983
3 Replies

10. Shell Programming and Scripting

Filtering log file with lines older than 10 days.

Hi, I am trying to compare epoch time in a huge log file (2 million lines) with todays date. I have to create two files one which has lines older than 10 days and another file with less than 10 days. I am using while do but it takes forever to complete the script. It would be helpful if you can... (12 Replies)
Discussion started by: shunya
12 Replies
QDateTimeEdit(3qt)														QDateTimeEdit(3qt)

NAME
QDateTimeEdit - Combines a QDateEdit and QTimeEdit widget into a single widget for editing datetimes SYNOPSIS
#include <qdatetimeedit.h> Inherits QWidget. Public Members QDateTimeEdit ( QWidget * parent = 0, const char * name = 0 ) QDateTimeEdit ( const QDateTime & datetime, QWidget * parent = 0, const char * name = 0 ) ~QDateTimeEdit () QDateTime dateTime () const QDateEdit * dateEdit () QTimeEdit * timeEdit () virtual void setAutoAdvance ( bool advance ) bool autoAdvance () const Public Slots virtual void setDateTime ( const QDateTime & dt ) Signals void valueChanged ( const QDateTime & datetime ) Properties QDateTime dateTime - the editor's datetime value DESCRIPTION
The QDateTimeEdit class combines a QDateEdit and QTimeEdit widget into a single widget for editing datetimes. QDateTimeEdit consists of a QDateEdit and QTimeEdit widget placed side by side and offers the functionality of both. The user can edit the date and time by using the keyboard or the arrow keys to increase/decrease date or time values. The Tab key can be used to move from section to section within the QDateTimeEdit widget, and the user can be moved automatically when they complete a section using setAutoAdvance(). The datetime can be set with setDateTime(). The date format is read from the system's locale settings. It is set to year, month, day order if that is not possible. See QDateEdit::setOrder() to change this. Times appear in the order hours, minutes, seconds using the 24 hour clock. It is recommended that the QDateTimeEdit is initialised with a datetime, e.g. QDateTimeEdit *dateTimeEdit = new QDateTimeEdit( QDateTime::currentDateTime(), this ); dateTimeEdit->dateEdit()->setRange( QDateTime::currentDate(), QDateTime::currentDate().addDays( 7 ) ); Here we've created a new QDateTimeEdit set to the current date and time, and set the date to have a minimum date of now and a maximum date of a week from now. Terminology: A QDateEdit widget consists of three 'sections', one each for the year, month and day. Similarly a QTimeEdit consists of three sections, one each for the hour, minute and second. The character that separates each date section is specified with setDateSeparator(); similarly setTimeSeparator() is used for the time sections. <center> [Image Omitted] </center> See also QDateEdit, QTimeEdit, Advanced Widgets, and Time and Date. MEMBER FUNCTION DOCUMENTATION
QDateTimeEdit::QDateTimeEdit ( QWidget * parent = 0, const char * name = 0 ) Constructs an empty datetime edit with parent parent and called name. QDateTimeEdit::QDateTimeEdit ( const QDateTime & datetime, QWidget * parent = 0, const char * name = 0 ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Constructs a datetime edit with the initial value datetime, parent parent and called name. QDateTimeEdit::~QDateTimeEdit () Destroys the object and frees any allocated resources. bool QDateTimeEdit::autoAdvance () const Returns TRUE if auto-advance is enabled, otherwise returns FALSE. See also setAutoAdvance(). QDateEdit * QDateTimeEdit::dateEdit () Returns the internal widget used for editing the date part of the datetime. QDateTime QDateTimeEdit::dateTime () const Returns the editor's datetime value. See the "dateTime" property for details. void QDateTimeEdit::setAutoAdvance ( bool advance ) [virtual] Sets the auto advance property of the editor to advance. If set to TRUE, the editor will automatically advance focus to the next date or time section if the user has completed a section. void QDateTimeEdit::setDateTime ( const QDateTime & dt ) [virtual slot] Sets the editor's datetime value to dt. See the "dateTime" property for details. QTimeEdit * QDateTimeEdit::timeEdit () Returns the internal widget used for editing the time part of the datetime. void QDateTimeEdit::valueChanged ( const QDateTime & datetime ) [signal] This signal is emitted every time the date or time changes. The datetime argument is the new datetime. Property Documentation QDateTime dateTime This property holds the editor's datetime value. The datetime edit's datetime which may be an invalid datetime. Set this property's value with setDateTime() and get this property's value with dateTime(). SEE ALSO
http://doc.trolltech.com/qdatetimeedit.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qdatetimeedit.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QDateTimeEdit(3qt)
All times are GMT -4. The time now is 05:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy