Apple 系统的文件格式 HFS+ 和 APFS 都支持透明压缩,需要使用第三方开源工具开启这个特性:
如果你使用的包管理工具是 MacPorts,安装命令是:
$ sudo port install afscompress
如果你使用的包管理工具是 HomeBrew,安装命令是:
$ brew install afsctool
使用方法很简单,以下命令中的 afscompress
是使用 MacPorts 安装的,如果是 HomeBrew 安装的则要改成 afsctool
:
压缩某个目录或者文件:
$ afscompress -c ~/Documents
查看压缩效果:
$ afscompress -v ~/Documents
Total number of files: 15215
Total number of folders: 1550
Total number of items (number of files + number of folders): 16765
Folder size (uncompressed; reported size by Mac OS 10.6+ Finder): 1830398656 bytes / 1.87 GB (gigabytes, base-10)
Folder size (compressed): 1327370600 bytes / 1.24 GiB
Compression savings: 27.5% over 14997 of 15215 files
Approximate total folder size (files + file overhead + folder overhead): 1328291569 bytes / 1.24 GiB
值得注意的是,并不是所有类型的文件都会被压缩,比如视频文件是不支持压缩的。