[英]Upload to aws s3 using cli without folder path
我想在 aws s3 上上傳一個file.txt
,它位於main/part1/part2/file.txt
類的地方,其中part1
和part2
是未知的(這些文件夾總是會改變)。 我可以使用命令aws s3 cp./main s3://mybucket --exclude "*" --include "*.txt" --recursive
來做到這一點,但是在我的存儲桶中,我的文件位於part1/part2/file.txt
。 我希望file.txt
位於存儲桶的底部,而不是在part1/part2
內
part1
部分和part2
部分不斷變化,這可能嗎?
for dir1 in $(ls main); do
for dir2 in $(ls main/$dir1); do
aws s3 cp ./main/$dir1/$dir2/ s3://my-bucket --exclude "*" --include "*.txt" --recursive
done
done
upload: main/part1/part2/file.txt to s3://my-bucket/file.txt
upload: main/part11/part22/file2.txt to s3://my-bucket/file2.txt
如果main
一次永遠不會包含超過 1 個子目錄( part1
)並且該子目錄一次永遠不會包含超過 1 個子目錄( part2
),則以下將起作用:
aws s3 cp ./main/*/*/ s3://my-bucket --exclude "*" --include "*.txt" --recursive
upload: main/part1/part2/file.txt to s3://my-bucket/file.txt
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.