truncate a 2gig file ?

Peter Barker pbarker at
Wed Nov 27 17:20:06 EST 2002

On Wed, 27 Nov 2002, Simon Burton wrote:

> I have a 2gig file (leunig's interview thismorning on ABC classic fm)
> that i only need the first 700mb of, i haven't the disk space to
> dd it, i'm looking to just chop off the last 1.3gig or so.

perl -e 'truncate "foo", 4096 or die qq%Bugger: \$!%';

where foo is your file, 4096 is 1.3G :-)

> Any commands to do this? Can clib do this?

Oddly, no, not that I've come across in the standard toolkit.

> Also i have wanted to zero length a file in the past,
> ie. just keeping the filename....

In various shells: ">filename"

> Simon Burton.

Peter Barker                          |   N    _--_|\ /---- Barham, Vic 
Programmer,Sysadmin,Geek              | W + E /     /\                
pbarker at         |   S   \_,--?_*<-- Canberra      
You need a bigger hammer.             |             v    [35S, 149E]   
"Yes, it takes a great deal of flexibility to blow a goat" -- Anon.

More information about the linux mailing list