使用功能
truncate
http://linux.die.net/man/2/truncate
int truncate(const char *path, off_t length);int ftruncate(int fd, off_t length);
truncate采用文件名
ftruncate采用打开的文件描述符
两者都将文件长度设置为,
length因此它会被截断或拉长(在后一种情况下,文件的其余部分将填充为NULL / ZERO)。
[edit]
truncate(Linux shell命令)也将起作用
**SYNTAX**truncate -s integer <filename> **OPTIONS**-s number specify the new file length. If the new length is smaller than the current filelength data is lost. If the new length is greater the file is padded with 0. You can specify a magnitude character to ease large numbers:b or B size is bytes.k size is 1000 bytes.K size is 1024 bytes.m size is 10^6 bytes.M size is 1024^2 bytes.g size is 10^9 bytes.G size is 1024^3 bytes.**EXAMPLES**To shrink a file to 10 bytes:truncate -s 10 /tmp/fooTo enlarge or shrink a file to 345 Megabytes:truncate -s 345M /tmp/foo
[/编辑]



