LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-27-2004, 05:32 AM   #1
box_l
Member
 
Registered: Jul 2003
Location: Hereford,England
Distribution: mandrake 10 , Novell Desktop Linux (suse) , knoppix
Posts: 85

Rep: Reputation: 15
put date as part of filename


i have a script that writes an image file to a server how can i include the date as part of the filename?
 
Old 07-27-2004, 05:56 AM   #2
sterrenkijker
Member
 
Registered: Mar 2004
Location: the Netherlands
Distribution: Debian Sarge
Posts: 302

Rep: Reputation: 31
I don't know how your script works, but if it's bash you can use the 'date' command to ask for the date, or use $(date) so you will have a date-string. Take a look at date's man-page for giving the date the right format.
 
Old 07-27-2004, 05:58 AM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
easy, say you want 04-07-27.jpg :

filename=`date "+%y-%m-%d"`.jpg
echo $filename


do man date to learn more date formatting

[edit]
as sterrenkijker said
 
Old 07-27-2004, 06:17 AM   #4
box_l
Member
 
Registered: Jul 2003
Location: Hereford,England
Distribution: mandrake 10 , Novell Desktop Linux (suse) , knoppix
Posts: 85

Original Poster
Rep: Reputation: 15
thankyou both!

i knew about date but was unsure of how to put it into the file name.

ta

Box
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
logrotate with date in filename ptp Linux - Newbie 1 04-14-2011 10:55 AM
filename.part << partially downloaded files... jimjamjahaa Linux - Newbie 2 04-04-2005 11:48 AM
Getting the first part of a filename in a BASH script trevelluk Programming 3 02-15-2005 01:06 AM
use date as output filename? wijnands Linux - Newbie 1 05-12-2004 03:39 PM
how to add date to filename x2000koh Programming 1 07-08-2003 09:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration