a technical how to

Matt Emmerton matt at gsicomp.on.ca
Mon Dec 8 20:44:44 PST 2003


> In the last episode (Dec 08), Kevin D. Kinsey, DaleCo, S.P. said:
> > Harald Schmalzbauer wrote:
> > >On Tuesday 09 December 2003 02:51, homeyra g wrote:
> > >>So, I hope this is the right address for this type of question. If
> > >>not would you please forward this and/or let me know the correct
> > >>address.
> > >>
> > >>Thanks,
> > >>
> > >>Here is the question: How to truncate a file from the begining to a
> > >>certain point in the file?
>
> If you're writing a script, use the /usr/bin/truncate command.  If
> you're writing a C program, use the truncate() function.

truncate() essentially alters the "end-of-file" position, by decreasing it
(truncating the file) or increasing it (extending the file.)

I think what the requestor wants is a way to adjust the "start-of-file"
position, which would effectively "truncate [sic] a file from the beginning
to a certain point in the file".

One way to accomplish this is as follows:

split -b 1024 /path/to/data
rm <files that represent data to "truncate">
cat * > data.new

--
Matt Emmerton



More information about the freebsd-questions mailing list