I want to shrink a file's size by brute-force, that is, I don't care about the rest, I just want to cut the file, say by half, and discard the rest.
The first thing that comes to mind is Perl's truncate. I'm following the example on that page and did the exactly the same thing:
seq 9 > test.txt ls -l test.txt perl -we 'open( FILE, "< ./test.txt" ) && truncate( FILE, 8 ) && close(FILE);'
But the file still has the same size:
$ ls -lgG test.txt -rw-rw---- 1 18 2013-08-08 09:49 test.txt
How can I make this work?