[NBLUG/talk] perl script to rename file with a julian date

Lincoln Peters sampln at sbcglobal.net
Tue Feb 3 16:14:01 PST 2004


On Tue, 2004-02-03 at 15:46, Dave Cooper wrote:
> Well I've been playing around, with no success...
> 
> I have 2 files in a /dir
> 
> fileA.rpt and fileB.rpt
> 
> everynight @ 2000 I need to rename the files with the julian date as the 
> extension....
> 
> Trying to stay with perl...
> 
> my work looks and is very tacky, so I'll not post my attempt...

Not a perl solution, but how about using the following line (or a
variant thereof) in a BASH script:

mv "$file" "$file-`date | tr \  _ | tr \: .`"

(notice two spaces between the '\' and '_' symbols.  If you only have
one space, it will not work.)

I find that very useful when making backups with the "tar" utility.  It
will append to the filename a date in the form of:

Tue_Feb__3_16.18.18_PST_2004

-- 
Lincoln Peters <sampln at sbcglobal.net>




More information about the talk mailing list