[TriLUG] Truncating a file

Brian A. Henning lugmail at cheetah.dynip.com
Sat Jan 24 18:13:46 EST 2004


Try this, although it may not be the most efficent:

% dd bs=1 cbs=1 count=<desired_size_in_bytes> if=the.file.you.have
of=the.file.clipped

According to the dd manpage, bs=1 should force dd to read and write 1 byte
at a time, and cbs=1 should force dd to convert 1 byte at a time..  To me
this seems redundant; cbs=1 might not be necessary.

Clearly I'm no expert on this; I'm just feeling chatty and I happen to be
near my mailbox. :-)

Okay, just tried it on a small test file, and it appears to work!

HTH.

Cheers,
~Brian




More information about the TriLUG mailing list