3

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.

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?

Thanks in advance.

1
  • Are you sure you didn't use single quotes? -o 'some file $(date +"%H:%M").txt' would produce the behavior you describe. Commented May 24, 2016 at 13:23

1 Answer 1

8

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

curl -o prefix-$(date +%H-%M) http://example.com/
Sign up to request clarification or add additional context in comments.

1 Comment

Windows 11 powershell error Get-Date : Cannot bind parameter 'Date'. Cannot convert value "+%H-%M" to type "System.DateTime". Error: "String was not recognized as a valid DateTime." At line:1 char:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.