using find and curl to upload a directory contents

2019-04-13 01:29发布

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

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

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

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

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

I want my find command to return

directory1/file1
directory2/file1
directory2/file2

then this can be passed to my exec command

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

https://PATH_TO_NEXUS/trunk/directory1/file1

and what I want is

https://PATH_TO_NEXUS/directory1/file1

anyone got any ideas?

标签: bash curl nexus
1条回答
放荡不羁爱自由
2楼-- · 2019-04-13 02:17

Run your find command from inside the trunk directory:

cd trunk
find . -type f -exec curl --user user:pass --ftp-create-dirs -T {} https://PATH_TO_NEXUS/{} \;
查看更多
登录 后发表回答