*BSD News Article 99800


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!news.radio.cz!nntprelay.mathworks.com!howland.erols.net!news-peer.sprintlink.net!news-pull.sprintlink.net!news-in-east.sprintlink.net!news.sprintlink.net!Sprint!206.172.150.11!news1.bellglobal.com!sympatico.ca!not-for-mail
From: gbuchanan@on.sympatico.ca (Gardner Buchanan)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: how to cut a piece of file?
Date: 17 Jul 1997 00:49:06 GMT
Organization: Sympatico
Lines: 35
Message-ID: <5qjq62$pdt$1@news2symp>
References: <33CCD3A6.CADC65F7@mcnet.ch>
NNTP-Posting-Host: 206.172.244.144
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Newsreader: knews 0.9.7
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:44549

In article <33CCD3A6.CADC65F7@mcnet.ch>,
	Michel Rueger <Michel.Rueger@mcnet.ch> writes:

> I'm working on Free BSD 2.2.1 and I have to make a new file with the
> last 10Mb of  a 200Mb log file. How can I do that (without editing the
> file...! :))

Look at tail(1):

TAIL(1)                 FreeBSD General Commands Manual                TAIL(1)

NAME
     tail - display the last part of a file

SYNOPSIS
     tail [-f | -r] [-b number | -c number | -n number] [file ...]

DESCRIPTION
     The tail utility displays the contents of file or, by default, its stan-
     dard input, to the standard output.
       :
       :

Something like:

  tail -b 20480 200Mb-file > 10Mb-file

should do the trick.

Alternatively you could write a simple program based around read(2),
write(2) and lseek(2).

============================================
Gardner Buchanan    <gbuchanan@sympatico.ca>
Ottawa, ON