Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 06: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, 08:22
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 324
1. define 'trim'
2. define 'past/latest'
3. provide sample log file.
Reply With Quote
  #3 (permalink)  
Old 06-04-04, 11: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, 09: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 09:50.
Reply With Quote
  #5 (permalink)  
Old 06-07-04, 02: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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On