Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I've been trying to put a timestamp on some images I'm downloading from a webcam, but so far it's been saving the images with the names camera3_date'

here's my line that I enter:

wget --output-document=camera_3‘date +%Y-%m-%d_%H:%M:%S’.jpg [IP]/image.jpg

and then it downloads like such:

--2014-11-25 11:10:28--  [Couldn't Add this FTP link].jpg
           => “camera3_‘date”
Resolving +%y-%m-%d_%h... failed: Name or service not known.
wget: unable to resolve host address “+%y-%m-%d_%h”
--2014-11-25 11:10:28--  [http link .jpg not allowed]
Connecting to [IP]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 447143 (437K) [image/jpeg]
Saving to: “camera3_‘date”

100%[======================================>] 447,143      486K/s   in 0.9s

2014-11-25 11:10:29 (486 KB/s) - “camera3_‘date” saved [447143/447143]

FINISHED --2014-11-25 11:10:29--
Downloaded: 1 files, 437K in 0.9s (486 KB/s)

So I'm getting the image I want but I can't save the timestamp correctly, how should I fix this?

share|improve this question
    
wget -o "camera_3$(date +%F_%T).jpg" [IP]/image.jpg – Stéphane Chazelas Nov 25 '14 at 17:46
    
Yes that worked! Thanks! – Brad Flynn Nov 25 '14 at 17:59
up vote 1 down vote accepted

You have to use backticks (`) instead of fancy quotes ().

wget --output-document=camera_3`date +%Y-%m-%d_%H:%M:%S`.jpg [IP]/image.jpg

Or better yet use the sub command notation, $(...).

wget --output-document=camera_3$(date +%Y-%m-%d_%H:%M:%S).jpg [IP]/image.jpg

Additionally you can simply the formatting to date like so:

wget --output-document=camera_3$(date +%F_%T).jpg [IP]/image.jpg

The date macros %F and %T are shorthand for the %Y-%m-%d and %H:%M:%S formats.

share|improve this answer
    
Perfect! Thanks! – Brad Flynn Nov 25 '14 at 17:59
    
@BradFlynn - please remember to mark this as the accepted answer so other's know your issues' been resolved. – slm Nov 25 '14 at 18:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.