我有一个文件更改列表,例如:
/opt/lampp/htdocs/project/index.php
/opt/lampp/htdocs/project/css/styles.css
/opt/lampp/htdocs/project/css/styles001.css
/opt/lampp/htdocs/project/system/model/core.php
/opt/lampp/htdocs/project/system/controllers/admin/users.php
我如何使用 Linux 通过 FTP 一次性上传它们?
答案1
您可以找到如何执行此操作的示例这里。
从页面本身来看:
## upload the files
INPUT=/path/to/list_of_files_to_upload
LOCALBASE=/home/pete/website #local directory that corresponds to the root of the website
for ITEM in $(cat $INPUT); do
FILE=$(basename $ITEM)
LOCALDIR=$(dirname $ITEM)
if [ "$LOCALDIR" == "$LOCALBASE" ]; then
REMOTEDIR="/"
else
REMOTEDIR=${LOCALDIR#$LOCALBASE}
fi
## ftp starts here
ftp -v -n $SERVER <<END_OF_SESSION
user $USER $PASSW
$FILETYPE
lcd $LOCALDIR
cd $REMOTEDIR
put $FILE
bye
END_OF_SESSION
done