Results 1 to 5 of 5

Thread: Trim a log file

  1. #1
    Join Date
    May 2004
    Posts
    14

    Unanswered: 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

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    1. define 'trim'
    2. define 'past/latest'
    3. provide sample log file.

  3. #3
    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.

  4. #4
    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.
    Last edited by fla5do; 06-05-04 at 09:50.
    Greetings from germany
    Peter F.

  5. #5
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •