我尝试下载文件wget -P /var/www/html/wp-content/uploads/movies/2019/ -O love.mp4 https://example.com/video.mp4
但它将文件定位在root
而不是 /var/www/html/wp-content/uploads/movies/2019/
答案1
像这样 :
mkdir -p /var/www/html/wp-content/uploads/movies/2019
wget -O /var/www/html/wp-content/uploads/movies/2019/love.mp4 \
https://example.com/video.mp4
答案2
使用-O
和-P
可能无法按预期工作。如果您要下载一个文件,请尝试仅指定 -O。
wget -O /var/www/html/wp-content/uploads/movies/2019/love.mp4 \
https://example.com/video.mp4`
在此示例中,我在我的目录中获取了一个名为 love.mp4 的文件/var/www/html
。我以 sudo 身份运行该命令,因为我没有普通用户的权限。
user@server:/var/www/html$ sudo wget -O /var/www/html/love.mp4 https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_1920_18MG.mp4
--2020-06-09 20:00:43-- https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_1920_18MG.mp4
Resolving file-examples.com (file-examples.com)... 185.135.88.81
Connecting to file-examples.com (file-examples.com)|185.135.88.81|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17839845 (17M) [video/mp4]
Saving to: ‘/var/www/html/love.mp4’
/var/www/html/love.mp4 100%[==================================>] 17.01M 7.87MB/s in 2.2s
2020-06-09 20:00:46 (7.87 MB/s) - ‘/var/www/html/love.mp4’ saved [17839845/17839845]
user@server:/var/www/html$