Computing.Net > Forums > Unix > date-renaming files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

date-renaming files

Reply to Message Icon

Name: spiffin
Date: November 1, 2001 at 01:53:58 Pacific
Comment:

i'm trying to write a simple backup script
using rsync, tar and crontab .. but i want to
be able to rename a newly created
archive with the current date .. could
anyone point me in the right direction
please? thanks



Sponsored Link
Ads by Google

Response Number 1
Name: James Boothe
Date: November 1, 2001 at 06:52:26 Pacific
Reply:

I sometimes use dates in file naming, but I prefer sequential numbering since that is unique, and I still have the date stamp of the file to show me when it was created. When using dates, consider including hour and min, and maybe even sec. Following example uses only ymd. The nested command in back apostrophes is replaced by its output:

outfile=backup_`date +%Y%m%d`
/etc/fbackup -f $outfile ...
compress $outfile

If the utility does not let you name the output, but instead always outputs to some default file name, you can rename it after creation:

outfile=backup_`date +%Y%m%d`
/etc/mybackup_utility
mv backup.out $outfile
compress $outfile


0
Reply to Message Icon

Related Posts

See More


Lost MOUSE on ultra5 afte... Question related to unix ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: date-renaming files

Utility or script for renaming files on www.computing.net/answers/unix/utility-or-script-for-renaming-files-on-/2538.html

Renaming Files Globally www.computing.net/answers/unix/renaming-files-globally/2158.html

multiple renaming files & extension www.computing.net/answers/unix/multiple-renaming-files-amp-extension/6314.html