Nelson Castillo wrote:
> Well, this is silly. If you use dd to truncate a file this way you
> lose the trailing byte :)
>
> I really want to know : Is there another way to truncate a file in
> Linux?
>
> This would be a silly way to avoid wasting a byte to truncate a file
> to have 2 bytes with dd.
>
> ~$ echo 12345 > x
> ~$ dd if=x skip=1 bs=1 count=1 > t
> ~$ dd if=t seek=1 of=x count=1 bs=1
> ~$ cat x
> 12
>
> Regards,
> Nelson.-

I use trivial programs written in some other language to do the
truncating. For example, python:

  file('xxx').truncate(10*1024*1024*1024)

But do note that files created this way are sparse - and we have had
*drastic* performance problems with files that are sparse.

So I would recommend just writing zeros.

-- Naked




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
User-mode-linux-user mailing list
User-mode-linux-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-user

Reply via email to