Hem*_*ant 18 editors large-files hp-ux files
我有几个文件大小 > 1 GB。我需要从文件中删除最后几个字节。我该怎么做?我更喜欢就地编辑文件以节省磁盘空间。
我在 HP-UX 上。
使用可让您访问truncate系统调用的工具。您只能使用 POSIX 工具来完成。警告,在浏览器中输入;要特别小心,因为dd它比通常的 unix 命令更不能容忍错误。123456 是要保留的字节数。
dd if=/dev/null of=/file/to/truncate seek=1 bs=123456
Run Code Online (Sandbox Code Playgroud)
Perl 版本更具可读性:
perl -e 'truncate "$ARGV[0]", 123456 or die $!' /file/to/truncate
Run Code Online (Sandbox Code Playgroud)
例如,您可以使用 dd:
dd if=yourfile of=outname bs=4k count=thefirstX4kb
Run Code Online (Sandbox Code Playgroud)