Trim 1.0 review

Download
by rbytes.net on

Trim project removes a number of lines from the beginning of a file. Utility used to monitor and control the sizes of (log) files

License: Freeware
File size: 4K
Developer: Jem Berkes
0 stars award from rbytes.net

Trim project removes a number of lines from the beginning of a file.

Utility used to monitor and control the sizes of (log) files. Examines a text file to see if its length has exceeded a certain limit; if it has, Trim removes a certain number of lines from the beginning of the file. Ideal for use in crontab.

Usage: trim filename x y

If filename's length exceeds x bytes, then as many as
y lines are removed from the start of the text file. Exit codes:

0=OK, 1=can't open file, 2=can't create temp, 3=can't write to file,
255=syntax. Information messages are sent to stdout (1). Error messages to stderr (2).

I originally wrote the 'trim' utility because I needed something in my
crontab that would monitor the sizes of growing log files, and trim the
files when they grew too large.

trim access_log 1000000 100

This command will examine access_log to see if its length is greater
than 1000000 bytes. If the file's length exceeds the limit, then Trim
will remove 100 lines from the start of the text file.

If you are running Trim in a script, you may want to suppress normal
output but keep an eye out for errors. You can accomplish this with:

trim filename x y 1>null

This redirects stdout (1) to null, leaving stderr active. You can also
redirect errors to a file:

trim filename x y 2>error.log

Trim 1.0 keywords