21 users online | 21 Guests and 0 Registered

How to rename a file with the date stamped


Assuming that you have a directory /logs

This is the actual command that runs on one of my  cron jobs.

 

 

logwatch --detail=High --range=Today >/logs/watchdog.txt  && mv /logs/watchdog.txt /logs/"´date +%Y-%m-%d_%H´.txt" 

 

To rename a file

mv /logs/watchdog.txt /logs/"´date +%Y-%m-%d_%H´.txt" 

 

OR

dt=$( date +%Y%M%d ) && cp /var/Vol1/backup/pdf_form /var/Vol1/backup/"$dt"_pdf_form ;

Tags: date, rename file with date
Last update:
2012-08-21 01:14
Author:
Eric Pezoa
Revision:
1.1
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.

Records in this category

Tags

Sticky FAQs