将 find 与 curl 组合使用

发布于 2025-01-12 05:16:18 字数 393 浏览 6 评论 0原文

我使用下面的代码将数据发送到我的 NAS。正在创建的目录以句点结尾。我不想最后有句号。我怎样才能防止这种情况。 我的 NAS 上的目录现在如下: 目录:InluxDB。 子目录:(日期)为 07-03-2022

TEMPDIR="/tmp"
DESTDIRNAS="/Backups/InfluxDB"
DATE="$(date +%d-%m-%Y)"
BACKUPDIR="/tmp/influxdb"

cd $BACKUPDIR

find -type f -exec curl -u "USER:PASSWORD" --ftp-create-dirs -T {} "ftp://192.168.1.20/$DESTDIRNAS"{} \;

#delete tmp folder
rm -rf $BACKUPDIR

I use the code below to send data to my NAS. The directory being created ends with a period. I don't want a period at the end. How can I prevent this.
The dir on my NAS is now as follows:
Dir: InluxDB.
Subdir: (date) as 07-03-2022

TEMPDIR="/tmp"
DESTDIRNAS="/Backups/InfluxDB"
DATE="$(date +%d-%m-%Y)"
BACKUPDIR="/tmp/influxdb"

cd $BACKUPDIR

find -type f -exec curl -u "USER:PASSWORD" --ftp-create-dirs -T {} "ftp://192.168.1.20/$DESTDIRNAS"{} \;

#delete tmp folder
rm -rf $BACKUPDIR

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狠疯拽 2025-01-19 05:16:18

要使 find 输出具有完整/绝对路径,请使用 find "$PWD" -type f

建议使用 curl 命令:

find "$PWD" -type f -exec curl -u "USER:PASSWORD" --ftp-create-dirs -T {} "ftp://192.168.1.20/$DESTDIRNAS"{} \;

至于获取最后一个目录$BACKUPDIR

basename "$BACKUPDIR"

返回influxdb

dirname "$BACKUPDIR"

返回/tmp

To make find output with full/absolute path use find "$PWD" -type f

Suggesting the curl command:

find "$PWD" -type f -exec curl -u "USER:PASSWORD" --ftp-create-dirs -T {} "ftp://192.168.1.20/$DESTDIRNAS"{} \;

As for getting last directory in $BACKUPDIR

basename "$BACKUPDIR"

Returns influxdb

dirname "$BACKUPDIR"

Return /tmp

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文