在curl命令中将时间戳添加到文件名 [英] Add timestamp to filename in curl command

查看:115
本文介绍了在curl命令中将时间戳添加到文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找在使用curl命令从远程服务器下载文件后添加时间戳或仅将日期添加到文件名的方法.我知道您可以使用-o指定要命名的文件.我已经看到类似的建议:-o"somefile $(date + \"%H:%M \).txt"为了实现这一目标,但我无法完全正常工作,它只是将文件另存为"somefile $(date)",就像它无法将$识别为变量一样.

I'm looking to add a time stamp or just the date to a file name once it has been downloaded from a remote server using a curl command. I know you can use -o to specify what you want to name the file. I have seen suggestions like: -o "somefile $(date +\"%H:%M\").txt" to try to achieve this but I can't quite get it working, it just saves the file as 'somefile $(date' like it doesn't recognize $ as a variable.

有人知道使用curl或是否可以实现此目的的方法吗?

Does anyone know of a way to achieve this using curl or if it is possible?

还有另一种方法来创建带有日期的变量,然后将其附加到文件名上吗?

Is there another way to create a variable with the date and then append it onto the file name?

谢谢.

推荐答案

它与您显示的内容完全一样可以很好地工作:

It works perfectly fine with a variation of what you showed:

curl -o prefix-$(date +%H-%M) http://example.com/

这篇关于在curl命令中将时间戳添加到文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆