Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 15
Script add date to filename


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.

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

Rep: Reputation: 36
# 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, 08:12 AM   #3
LQ Newbie
Registered: Mar 2003
Posts: 25

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


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 11:55 AM
How do I add the current date to a filename? sammysrefuge Linux - Newbie 2 03-18-2005 03:43 PM
put date as part of filename box_l Programming 3 07-27-2004 07:17 AM
use date as output filename? wijnands Linux - Newbie 1 05-12-2004 04:39 PM
how to add date to filename x2000koh Programming 1 07-08-2003 10:44 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:01 PM.

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