rhge 发表于 2005-5-16 13:21:33

请教 linux 下的压缩

用winrar 可以把一个大文件分卷压缩, 请问linux/unix 有没有相应的命令?
比如5GB的一个大文件,压缩成6个左右500MB的小文件。
看了tar的文档,有个tape-length option, 不但不能压缩, 而且每个文件都要输入文件名。
有没有像winrar那样的?

felix 发表于 2005-5-16 13:28:42

Linux下也有rar,试试吧!不过没有RAR的图形界面!

Bluedata 发表于 2005-5-16 14:11:20

一个把文件拆分为任意大小的脚本。
#!/bin/bash

if [ -z "$2" -o ! -r "$1" ]; then
echo "Usage: mince [file] [chunk size]"
exit 255
fi

SIZE=`ls -l $1 | tr -s 'a-zA-Z -' ' ' | cut -f 3 -d ' '`
echo "size = $SIZE"

if [ $2 -gt $SIZE ]; then
echo "Your chunk size must be smaller than the file size!"
exit 254
fi

CHUNK=$2
TOTAL=0
PASS=0
while [ $TOTAL -lt $SIZE ]; do
PASS=$((PASS + 1))
echo "Creating $1.$PASS..."
dd conv=noerror if=$1 of=$1.$PASS bs=$CHUNK skip=$((PASS - 1)) count=1 2> /dev/null
TOTAL=$((TOTAL + CHUNK))
done

echo "Created $PASS chunks out of $1."

luronghui 发表于 2005-5-16 14:23:27

呵呵,还是自己写脚本方便!可是我是低手。。。。。呵呵
页: [1]
查看完整版本: 请教 linux 下的压缩