LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 06-02-2004, 04:52 AM   #1
amphion
LQ Newbie
 
Registered: Mar 2003
Posts: 25

Rep: Reputation: 15
Script add date to filename


Hi,

I need a simple script that adds the current date to the filename of a file.

I am struggling with a script but it doesn't work. I'm this far that I want the output off
date +%y%m%d
appended to the filename.

Thankz
 
Old 06-02-2004, 05:29 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Code:
# script=dname
#parameter  $1 is the existing file name
dt=`date +%y%m%d`
mv $1 $1$dt
usage: dname myfile
produces myfile040602
 
Old 06-02-2004, 07:12 AM   #3
amphion
LQ Newbie
 
Registered: Mar 2003
Posts: 25

Original Poster
Rep: Reputation: 15
Thankz.. that works fine.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How do I add the current date to a filename? sammysrefuge Linux - Newbie 2 03-18-2005 02:43 PM
put date as part of filename box_l Programming 3 07-27-2004 06:17 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


All times are GMT -5. The time now is 11:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration