![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compare date from db2 table to yesterday's Unix system date | sasaliasim | Shell Programming and Scripting | 9 | 12-01-2008 11:37 PM |
| How to list files that were added or modified on a certain date? | thoughts | UNIX for Dummies Questions & Answers | 8 | 02-20-2008 01:44 AM |
| Create a list of files that were modified after a given date. | rkka | UNIX for Dummies Questions & Answers | 4 | 01-22-2008 05:12 AM |
| Last Modified Date | cengiz | Shell Programming and Scripting | 12 | 06-28-2005 03:05 AM |
| compare date of files on different nodes | isacs | UNIX for Advanced & Expert Users | 3 | 03-12-2002 02:11 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
compare files in the system with last modified date
HI,
I have some files in my Linux machine that are very old and occupy a HUGe amount of space. I am trying to delete these files from the system so that it will be easy for me to add some files. I would like to know if this can done through a Perl or a shell script. What i want to do is i want to compare the files with the current date stamp and list all the files that are were untouched for more than TWO years. Please can some whe help me on how this can be done. I am new to Linux and need Guidance on this. Thanks, Sandeep |
|
||||
|
man test
Code:
file1 -nt file2
True if file1 exists and is newer than file2.
file1 -ot file2
True if file1 exists and is older than file2.
Code:
if test $candidate-file -ot $cutoff-file
then
echo $candidate-file
fi
|
|
||||
|
Hi Porter,
The script you have given is probably if i know the filename, but in my case i don't know the names of all the files( thats were the problem lies)....I need to find files that have not been changed from past two years by compariing them with respect to the last modified date. Also i am starter to shell scripting so please help me with the complete code. I really appreciate you time to look into this thread.Thanks so much. Please let me know your thoughts. Thanks, Sandeep |
|
||||
|
try
find directory ! -newer candidate | xargs ls -ld when that is showing you the correct files replace "ls -ld" with "rm" Note, it is your responsiblity to have the appropriate backups. Do not attempt this if you don't know what you are doing. |
|
||||
|
Quote:
|
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|