CURL SFTP - 如何在下载时保留最后修改日期
我正在尝试从另一台服务器下载文件,但我还需要获取文件的最后修改日期或最后时间戳。我使用curl sftp,这样我就不必每次运行它时都输入密码,并且我还将在perl 程序中运行curl 命令。
在 SFTP 中,我可以通过执行以下命令来保留它: get -p filename.txt
在我的curl 命令中,这就是我所做的:
curl -v -R -u user:userpass sftp://ip.add.re.ss:port/host/path/name/filename.txt > filename.txt
但是每当我运行此命令时,时间戳总是会更新。
有人可以帮我下载该文件并保留上次修改的日期和时间吗?
I'm trying to download a file from another server but I also need to get the last modified date or the last timestamp of the file. I use curl sftp so that I don't have to enter my password every time I run it and I'm also going to run the curl command in perl program.
In SFTP I can preserve it by doing this command: get -p filename.txt
In my curl command, this is what I did:
curl -v -R -u user:userpass sftp://ip.add.re.ss:port/host/path/name/filename.txt > filename.txt
But whenever I run this command, the timestamp is always updated.
Can someone help me to download the file and preserve the last modified date and time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
-R 不适用于
>
,当您使用
>
时,它需要-o
这并不是真正的curl命令,它是一个命令对于你的shell,它告诉你的shell将curl的输出保存到文件中,而你的shell不理解-R。但是-o告诉curl将输出保存到文件而不是打印文件,并且curl理解-R-R doesn't work with
>
it requires-o
when you use
>
that's not really a command for curl, it's a command for your shell, it tells your shell to save curl's output to a file, and your shell doesn't understand -R. but -o tells curl to save the output to a file instead of printing the file, and curl understands -R