Forum Moderators: bakedjake
My web host puts out logfiles on a daily basis, except they appear to be named:
log-(random10digitNumber).gz
I'm wondering if anybody can think of a shell script I can run that would rename them something like this:
log-(fileCreationDate).gz
I can figure out how to loop through the files, and rename them with a shell script, but I especially don't know how to access the fileCreationDate to put into the file name.
Any ideas? Thanks in advance...
Cameron
% foreach i ( * )
foreach? echo log-`ls -l $i ¦ awk '{printf "%s-%s", $6, $7}'`
foreach? end
There has to be a better way, but a quick look at the man pages for tcsh does not reveal a way of getting the mod date into a variable.
Looks like a candidate for a perl rather than shell script :)
log-(random10digitNumber).gz
I seriously doubt this is random. In fact, I'd be quite suprised if it were anything other than the number of seconds since the beginning of the epoch - AKA a unix timestamp. If you're going to attack it with PHP, try splitting out the number and running it through strftime();