How to create a file with ANY given size in Linux?

后端 未结 4 1459
Happy的楠姐
Happy的楠姐 2021-01-04 18:45

I have read this question: How to create a file with a given size in Linux?

But I havent got answer to my question.

I want to create a file of 372.07 MB,

4条回答
  •  -上瘾入骨i
    2021-01-04 19:31

    truncate - shrink or extend the size of a file to the specified size

    The following example truncates putty.log from 298 bytes to 235 bytes.

    root@ubuntu:~# ls -l putty.log 
    -rw-r--r-- 1 root root 298 2013-10-11 03:01 putty.log
    root@ubuntu:~# truncate putty.log -s 235
    root@ubuntu:~# ls -l putty.log 
    -rw-r--r-- 1 root root 235 2013-10-14 19:07 putty.log
    

提交回复
热议问题