bash 使用 find 和 curl 将目录内容上传到 Sonatype Nexus 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16417306/
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 05:22:40  来源:igfitidea点击:

using find and curl to upload a directory contents to Sonatype Nexus repository

bashcurlnexus

提问by user891380

I'm trying to use curl to upload a the contents of a directory to nexus via bash and am having a few issues in the command I'm using

我正在尝试使用 curl 通过 bash 将目录的内容上传到 nexus 并且在我使用的命令中遇到了一些问题

In short I want to do a find command on a specific directory and use the –exec {} action to do a curl to nexus

简而言之,我想在特定目录上执行 find 命令并使用 –exec {} 操作对 nexus 执行 curl

However my find command returns the file path including the source directory and I want to change this so I only show the contents not the full path

但是我的 find 命令返回包括源目录的文件路径,我想改变它,所以我只显示内容而不是完整路径

e.g. say I have a directory called trunk which contains these files and sub directories

例如说我有一个名为 trunk 的目录,其中包含这些文件和子目录

trunk/directory1/file1
trunk/directory2/file1
trunk/directory2/file2

I want my find command to return

我希望我的 find 命令返回

directory1/file1
directory2/file1
directory2/file2

then this can be passed to my exec command

然后这可以传递给我的 exec 命令

my current find command is:-

我当前的查找命令是:-

find trunk -type f -exec curl --user user:pass --ftp-create-dirs -T {} https://PATH_TO_NEXUS/{} \;

this works ok except the files being created in nexus are

这工作正常,除了在 nexus 中创建的文件是

https://PATH_TO_NEXUS/trunk/directory1/file1

and what I want is

我想要的是

https://PATH_TO_NEXUS/directory1/file1

anyone got any ideas?

有人有任何想法吗?

回答by Barmar

Run your findcommand from inside the trunkdirectory:

findtrunk目录中运行您的命令:

cd trunk
find . -type f -exec curl --user user:pass --ftp-create-dirs -T {} https://PATH_TO_NEXUS/{} \;