On Dec 8, 2003, at 8:51 PM, homeyra g wrote:
Here is the question: How to truncate a file from the
begining to a certain point in the file?

The question is whether this file is ASCII text so line-based tools (such as tail) work, or whether you are truncating a binary file, in which case "split -b" is probably a better bet.


If you've got a logfile named /var/log/messages, and you want to truncate that to the last 100 lines:

mv /var/log/messages /var/log/messages.$$
tail -100 < /var/log/messages.$$ > /var/log/messages
rm -f /var/log/messages.$$

Use "wc -l" and "grep -n" to identify where to truncate the file if it's not a fixed size that you want...

--
-Chuck

_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to