Truncating the first 100MB of a file in linux

后端 未结 8 2103
余生分开走
余生分开走 2020-12-13 10:11

I am referring to How can you concatenate two huge files with very little spare disk space?

I\'m in the midst of implementing the following:

  1. Allocate a
8条回答
  •  [愿得一人]
    2020-12-13 10:39

    I found I had to use a combination of fallocate and sed before the file would shrink in size, so I had a 43MB file and I want to get it down to around 5MB

    fallocate -p -o 0 -l 38m fallocate.log
    

    I noticed this filled the first line with a bunch of "nonsense" characters but my file was still 43MB in size

    I then used sed to delete the first line

    sed -i 1d fallocate.log
    

    and the file size is now 4.2MB in size.

提交回复
热议问题