我有一个 500mb 的文件。我只想保留前 5 mb。如何在“truncate”命令不可用(并且不能由自制软件安装)的 osx 上截断它?
小智 5
安装截断
brew 安装截断
将文件截断为 0 大小:
截断 -s 0 your_filename
我知道这是一个老问题,但从 2018 年 10 月开始,您可以通过自制程序安装它:
\n> brew info truncate\ntruncate: stable 0.9 (bottled), HEAD\nTruncates a file to a given size\nhttps://www.vanheusden.com/truncate/\n/usr/local/Cellar/truncate/0.9 (4 files, 49.3KB) *\n Poured from bottle on 2018-10-31 at 14:54:21\nFrom: https://github.com/Homebrew/homebrew-core/blob/master/Formula/truncate.rb\n==> Options\n--HEAD\n Install HEAD version\n==> Analytics\ninstall: 281 (30 days), 861 (90 days), 3,138 (365 days)\ninstall_on_request: 283 (30 days), 862 (90 days), 3,124 (365 days)\nbuild_error: 0 (30 days)\n
Run Code Online (Sandbox Code Playgroud)\n2022 年 9 月更新:
\n \xe2\x95\xb0\xe2\x94\x80 brew info coreutils\n ==> coreutils: stable 9.1 (bottled), HEAD\n GNU File, Shell, and Text utilities\n https://www.gnu.org/software/coreutils\n Conflicts with:\n aardvark_shell_utils (because both install `realpath` binaries)\n b2sum (because both install `b2sum` binaries)\n ganglia (because both install `gstat` binaries)\n gdu (because both install `gdu` binaries)\n idutils (because both install `gid` and `gid.1`)\n md5sha1sum (because both install `md5sum` and `sha1sum` binaries)\n truncate (because both install `truncate` binaries)\n uutils-coreutils (because coreutils and uutils-coreutils install the same binaries)\n Not installed\n From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/coreutils.rb\n License: GPL-3.0-or-later\n ==> Dependencies\n Required: gmp \xe2\x9c\x98\n ==> Options\n --HEAD\n Install HEAD version\n ==> Caveats\n Commands also provided by macOS and the commands dir, dircolors, vdir have been installed with the prefix "g".\n If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH with:\n PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH"\n ==> Analytics\n install: 86,771 (30 days), 265,204 (90 days), 1,257,918 (365 days)\n install-on-request: 62,729 (30 days), 190,281 (90 days), 885,118 (365 days)\n build-error: 132 (30 days)\n
Run Code Online (Sandbox Code Playgroud)\n