truncate a 2gig file ?

Brad Hards bhards at bigpond.net.au
Wed Nov 27 17:44:58 EST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 27 Nov 2002 17:20, Peter Barker wrote:
> 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 :-)
In python, something of the form:
>>> myfile = file("foo", "a")
>>> myfile.truncate(4096)

is probably about equivalent, although perhaps a bit more readable :)

Brad

- -- 
http://linux.conf.au. 22-25Jan2003. Perth, Aust. I'm registered. Are you?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE95GnvW6pHgIdAuOMRAls0AJ9FCGm4Ob7EjLBDzAgAKC+bBPF1EQCghb5I
brX8UrAgOCZLcBWThZkGiyo=
=NjdK
-----END PGP SIGNATURE-----




More information about the linux mailing list