代碼: $ tar cvf - . | gzip -c -1 | ssh user@host "cat > remotefile.gz" $ tar czvf - . | ssh user@host "cat > remote.tar.gz" $ ssh target_address cat < localfile ">" remotefile $ ssh target_address cat < localfile - ">" remotefile $ cat localfile | ssh target_address cat ">" remotefile $ cat localfile | ssh target_address cat - ">" remotefile 注: 以上命令行中的 大於號> 兩邊有雙引號(" ") , 小於號< 兩邊則沒有。 $ dd if=localfile | ssh target_address dd of=remotefile $ ssh target_address cat remotefile.tgz )" $ ( cd SOURCEDIR && tar cvf - . | gzip -1 -) | ssh target_address "(cd DESTDIR && cat - > remotefile.tgz )" $ ssh target_address "( nc -l -p 9210 > remotefile & )" && cat source-file | gzip -1 - | nc target_address 9210 $ cat localfile | gzip -1 - | ssh target_address cat ">" remotefile.gz SSH PULL(從遠程獲取到本地):
代碼: $ ssh target_address cat remotefile > localfile $ ssh target_address dd if=remotefile | dd of=localfile $ ssh target_address cat " localfile $ ssh target_address cat "localfile SSH COMPARE(本地和遠程文件比較):
代碼: 用遠程計算機CPU執行比較指令 $ ssh target_address cat remotefile | diff - localfile $ cat localfile | ssh target_address diff - remotefile
用本地計算機CPU執行比較指令 $ ssh target_address cat get file.gif "| xv -" $ ftp> get README "| more" FTP PUSH(從本地發送到遠程):
代碼: $ ftp> put "| tar cvf - ." myfile.tar $ ftp> put "| tar cvf - . | gzip " myfile.tar.gz FTP PULL(從遠程獲取到本地):
代碼: $ ftp> get myfile.tar "| tar xvf -"
不錯,很喜歡。。tar/cat/dd 這幾個命令配合 ssh,非常方便。
對了,我覺得把整個語句都包括進來我覺得比較好。當然,也可以用 tar zcvf - . 來代替 gzip,看網絡速度決定了。:)。 $ tar cvf - . | gzip -c -1 | ssh user@host cat ">" remotefile.gz -> $ tar cvf - . | gzip -c -1 | ssh user@host "cat > remotefile.gz"