If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Trim a log file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-04-04, 05:03
wanna13e wanna13e is offline
Registered User
 
Join Date: May 2004
Posts: 14
Trim a log file

Hi All,

I'm a newbie in unix. Currently I have this log file that contain past reords and the latest. How should I trim the log file which allow me to keep the recently record of the data?

Thanks
Reply With Quote
  #2 (permalink)  
Old 06-04-04, 07:22
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
1. define 'trim'
2. define 'past/latest'
3. provide sample log file.
Reply With Quote
  #3 (permalink)  
Old 06-04-04, 10:31
wanna13e wanna13e is offline
Registered User
 
Join Date: May 2004
Posts: 14
Hi vgersh99,

Sorry for the confusion. As I got a log file which is appended daily after my file transfer. There will be a time stamp and as this log file had not been cleared since a year back. I would like to delete the top part of the file which is back dated. I would like to keep a reference of three months.

The header of the file goes like this;

Wed 2 Jun 2004 1600........


Thks alot.
Reply With Quote
  #4 (permalink)  
Old 06-05-04, 08:36
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
Hi wanna,
if there is one line daily append to your logfile then use
tail -90 logfile > file; mv file logfile

else

tail -90*[lines daily]

If you want another solution, please give us more informations about your logfile.
__________________
Greetings from germany
Peter F.

Last edited by fla5do; 06-05-04 at 08:50.
Reply With Quote
  #5 (permalink)  
Old 06-07-04, 01:39
wanna13e wanna13e is offline
Registered User
 
Join Date: May 2004
Posts: 14
Quote:
Originally Posted by fla5do
Hi wanna,
if there is one line daily append to your logfile then use
tail -90 logfile > file; mv file logfile

else

tail -90*[lines daily]

If you want another solution, please give us more informations about your logfile.
Hi Peter,

Thks alot for the help u given me. The command works perfectly.

Rgds.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On