Unix 格式化在输出之前查找它';在下一个命令中使用

Unix 格式化在输出之前查找它';在下一个命令中使用,unix,curl,ftp,terminal,find,Unix,Curl,Ftp,Terminal,Find,我正在使用以下命令使用find和curl将文件批量上载到FTP服务器: find /path/to/target/folder -not -path '*/\.*' -type f -exec curl -u username:password --ftp-create-dirs -T {} ftp://ftp.myserver.com/public/{} \; 问题是find的输出路径如下 /full/path/from/root/to/file.txt 因此,在FTP服务器上,我将文件上

我正在使用以下命令使用find和curl将文件批量上载到FTP服务器:

find /path/to/target/folder -not -path '*/\.*' -type f -exec curl -u username:password --ftp-create-dirs -T {} ftp://ftp.myserver.com/public/{} \;
问题是find的输出路径如下

/full/path/from/root/to/file.txt
因此,在FTP服务器上,我将文件上载到

ftp.myserver.com/public/full/path/from/root/to/file.txt
而不是

ftp.myserver.com/public/relative/path/to/file.txt

目标是将目标文件夹中的所有文件和文件夹上载到公用文件夹,但这个问题正在破坏文件结构。有没有一种方法可以编辑find输出以在路径进入curl之前对其进行修剪?

不确定您希望在路径中最终得到什么,但这应该会给您一个想法。诀窍是执行
sh
,允许您修改路径并运行命令

find . -type f -exec sh -c 'joe=$(basename {}); echo $joe' \;

使用相对路径作为
find
的第一个参数-我的意思是
cd
到文件所在的位置,然后执行
查找。有些东西
这就是我想要的,但是你对我的问题的评论以一种更简单的方式解决了我的问题。非常感谢。