truncate
名称
truncate - 收缩或者扩展一个文件的大小
简介
truncate OPTION... FILE...
描述
收缩或者扩展一个文件的大小
如果FILE参数表示的文件不存在,那么将创建该文件。
如果FILE比标示的大小大,那么额外的数据将会丢失。如果文件更小,那么其余的部分将会被0填充。
长选项的强制参数,对于短选项来说,也是强制的。
-c, --no-create 不创建任何文件
-o, --io-blocks 将SIZE作为IO块的数量,而不是字节大小
-r, --reference=RFILE RFILE的基大小
-s, --size=SIZE 设置或调整文件大小
--help display this help and exit 显示帮助信息并推出程序
--version 输出版本信息并退出程序
The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and so on.
SIZE may also be prefixed by one of the following modifying characters: '+' extend by, '-' reduce by, '<' at most, '>' at least, '/' round down to multiple of, '%' round up to multiple of.
作者
Padraig Brady
报告Bug
GNU coreutils online help: https://www.gnu.org/software/coreutils/ Report any translation bugs to https://translationproject.org/team/
版权
Copyright © 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
其他
dd(1), truncate(2), ftruncate(2)
Full documentation https://www.gnu.org/software/coreutils/truncate or available locally via: info '(coreutils) truncate invocation'
示例
若bin.dat文件不存在,将会创建一个1024字节的文件,并用0填充该文件的每一个比特。
truncate -s 1k bin.dat