用于传大文件的 one-liner

个人偏爱传大文件前用 lzma 进行压缩,碰巧这两天需要通过 ssh 传送大文件,写了句趁手的 one-liner,备忘在此。

tar --lzma -cf <file_or_dir_name> | ssh <host> "cd <target_directory> && tar --lzma -xf -"

不过对于 Mac 用户来说,系统自带的 tar 并不支持 lzma 算法,需要通过 mac-port 安装 lzmautils,那么更具兼容性的 one-liner 如下:

tar cf <file_or_dir_name> | lzma -zc - | ssh <host> "cd <target_directory> && tar --lzma -xf -"

当时用 mac-port 安装的是 lzma_alone,写起来就像是这个样子:
tar cf <file_or_dir_name> | lzma_alone e -siso | ssh <host> "cd <target_directory> && tar --lzma -xf -"
--
Twitter: http://www.twitter.com/leechael

Comments (0)

Leave a comment...

 
Got an account with one of these? Login here, or just enter your comment below.
Posterous-login    Connect    twitter



 

About