Computing.Net > Forums > Unix > Rename files older than 2 days

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Rename files older than 2 days

Reply to Message Icon

Name: Srinivas
Date: November 10, 2002 at 12:33:32 Pacific
OS: UNIX
CPU/Ram: SUN Solaris
Comment:

I am new to shell scripting. The requirement is as follows:

At the beginning of the script, check file creation date. If it's more than 2 days old, rename the file with prefix "backlog".

I would really appreciate any input/ solutions.




Sponsored Link
Ads by Google

Response Number 1
Name: Frank
Date: November 11, 2002 at 02:30:36 Pacific
Reply:

Hi,

just use:
for i in `find /directory -mtime +2 -print`
do
mv $i $i.backlog
done

not tested but mtime +2 should show you files older 2 day's.
Please check against man page.

mfg Frank


0
Reply to Message Icon

Related Posts

See More







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: Rename files older than 2 days

deleting files older than 2 days www.computing.net/answers/unix/deleting-files-older-than-2-days/4394.html

Delete Files Older Than 2 Weeks www.computing.net/answers/unix/delete-files-older-than-2-weeks/4564.html

renaming files based on date arguments www.computing.net/answers/unix/renaming-files-based-on-date-arguments/2499.html