目录
内容来源:
GUN : Coreutils - GNU core utilities
busybox v1.36.1 : 【busybox记录】【shell指令】基于的Busybox的版本和下载方式-CSDN博客
【GUN】【truncate】指令介绍
truncate: 缩小或扩展文件的大小
truncate 将每个文件的大小缩小或扩展到指定的大小。
简介:
truncate option... file...
创建任何不存在的文件。
如果文件大于指定的大小,则多余的数据将丢失。如果文件较短,则对其进行扩展,并且稀疏的扩展部分(或洞)读取为零字节。
程序接受以下选项。请参见第2章[常用选项],第2页。
‘-c’
‘--no-create’
不要创建不存在的文件。
‘-o’
‘--io-blocks’
将大小视为文件的I/O块数,而不是字节数。
‘-r rfile’
‘--reference=rfile’
每个文件的大小以rfile的大小为基础。
‘-s size’
‘--size=size’
根据大小设置或调整每个文件的大小。大小以字节为单位,除非指定了 --io-blocks。size可以是,也可以是一个可选的整数,后跟下列相乘后缀之一:
‘KB’ => 1000 (KiloBytes)
‘K’ => 1024 (KibiBytes)
‘MB’ => 1000*1000 (MegaBytes)
‘M’ => 1024*1024 (MebiBytes)
‘GB’ => 1000*1000*1000 (GigaBytes)
‘G’ => 1024*1024*1024 (GibiBytes)
等等‘T’, ‘P’, ‘E’, ‘Z’, ‘Y’, ‘R’,‘Q’。也可以使用二进制前缀:‘KiB’=‘K’, ‘MiB’=‘M’,等等。
Size也可以加上以下前缀之一,以根据当前大小调整每个文件的大小:
‘+’ => 超出
‘-’ => 减少
‘<’ => 最多
‘>’ => 至少
‘/’ => 舍入到的倍数
‘%’ => 四舍五入到的倍数
退出状态为0表示成功,非0表示失败。
【busybox】【truncate】指令介绍
NA
【linux】【truncate】指令介绍
[root@localhost bin]# truncate --help
用法:truncate 选项... 文件...
Shrink or extend the size of each FILE to the specified size
A FILE argument that does not exist is created.
If a FILE is larger than the specified size, the extra data is lost.
If a FILE is shorter, it is extended and the extended part (hole)
reads as zero bytes.
必选参数对长短选项同时适用。
-c, --no-create 不创建文件
-o, --io-blocks 将SIZE 视为IO 块数而不使用字节数
-r, --reference=RFILE base size on RFILE
-s, --size=SIZE set or adjust the file size by SIZE bytes
--help 显示此帮助信息并退出
--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).
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.
GNU coreutils 在线帮助:<https://www.gnu.org/software/coreutils/>
请向 <http://translationproject.org/team/zh_CN.html> 报告 truncate 的翻译错误
完整文档请见:<https://www.gnu.org/software/coreutils/truncate>
或者在本地使用:info '(coreutils) truncate invocation'
使用示例:
NA