Bash Zip 脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8535325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:11:03  来源:igfitidea点击:

Bash Zip Script

linuxbashunixzip

提问by DarkMantis

I have written a script which (in theory) should zip all the contents of a folder (including subfolders and what not).

我写了一个脚本(理论上)应该压缩文件夹的所有内容(包括子文件夹和什么不是)。

However, when it's ran, it just includes one folder.

但是,当它运行时,它只包含一个文件夹。

Could you please help.

能否请你帮忙。

Here is the script:

这是脚本:

#!/bin/sh

# pull the svn files
cd /path/to/my/svn/folder
svn update

#Zip (tar gzip) up the folder
zip -r updateZip trunk/*

sleep 1


USERNAME="******"
PASSWORD="******"
SERVER="127.0.0.1"

# local directory to pickup zip file
FILE="updateZip.zip"

# remote server directory to upload backup
BACKUPDIR="my/backup/dir/"

# login to remote server
ftp -n -i $SERVER <<EOF
user $USERNAME $PASSWORD
cd $BACKUPDIR
mput $FILE
quit
EOF

回答by Justin Randall

Zip (tar gzip) up the folder

压缩 (tar gzip) 文件夹

zip -r updateZip trunk/*

If you want a tar.gz, try

如果你想要一个 tar.gz,试试

$ tar zcvf updateZip.tar.gz trunk/*

回答by djhaskin987

To zip up a folder and all its contents in a g-zipped tarball, simply enter

要将文件夹及其所有内容压缩到 g 压缩的 tarball 中,只需输入

tar czf trunk.tar.gz trunk/

That should do it.

那应该这样做。