Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Generate  a filename that include date and time

Posted on 2013-11-13
7
Medium Priority
?
476 Views
Last Modified: 2013-11-13
Hi,

I'm using in Ubuntu the command "import capture.png" to save a screen capture to the file capture.png, but I need that every time that I run this command, the filename will be updated include the date and time , for example:

capture2013-11-14-2200.png or something like this

I try to with the command "import capture$date(%Y-%m%d)" but doesn't work.

Could you give me the command to dynamic generate the filename including datetime stamp?

Thanks in advance
0
Comment
Question by:lnrivera
  • 3
  • 3
7 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 39644043
import capture$(date +%Y-%m-%d-%H%M).png
0
 

Author Comment

by:lnrivera
ID: 39644111
Thanks, but your command generate a file named "capture$(date +%Y-%m-%d-%H%M).png"

I see that between date and + there are a space, I try with and without space with the same results

I'm using Ubuntu 10.04 LTS

Regards
0
 
LVL 85

Expert Comment

by:ozo
ID: 39644118
Which shell are you using?
If it doesn't understand $(date +%Y-%m-%d-%H%M), try `date +%Y-%m-%d-%H%M`
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lnrivera
ID: 39644124
The standard for Ubuntu, I think that is bash.

The other option is including the character ' ?
0
 
LVL 85

Expert Comment

by:ozo
ID: 39644150
bash understands $(), what was the exact command you used?
Where do you want to include the character ' ?
You can include it literally by enclosing it in "'", otherwise $() and `` would both be disabled inside ''
0
 
LVL 48

Expert Comment

by:Tintin
ID: 39644328
import capture$(date +%Y-%m-%d-%H%M).png

won't produce a file called

capture$(date +%Y-%m-%d-%H%M).png

Can you please copy/paste the exact command you are running.
0
 

Author Closing Comment

by:lnrivera
ID: 39644376
Sorry, now works fine, I think tha we had a typing mistake
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month13 days, 1 hour left to enroll

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question