I was givin the task to clear up space in one of our directories. I was wondering if their was an ls command that I can search for a certain date (i.e. all files created in 2005) to display those files and then use a wildcard to delete all files created in a certain year. If so, this would make my life alot easier. I appreciate any help.
you can use the find command as below to find the files that have been modified more than two days ago and delete them:
find /ect -type f -mtime +2 -exec rm -fr {} \;
for more info see the man find
I see that the help you guys have givin me so far are a start. Is their not a way you can search by the YEAR instead of "how many days" a file was lost modified or accessed? Let me know either way please.
The following commands display files between a certain date range:
## Creates a file with date of 01/Jan/2006 00:00
touch -m 0101000006 $$START_FILE
## Creates a file with date of 01/Jan/2007 00:00
touch -m 0101000007 $$END_FILE
## List files in date order and display only those in between
## $$START_FILE and $$END_FILE
ls -lt | sed -n "/$$END_FILE/,/$$START_FILE/p"
## Remove both temporary files.
rm -f $$START_FILE
rm -f $$END_FILE
Please run the commands mentioned in the previous post.Once you confirm the results,try running the above command,here "ok" used inplace od "exec" will wait for you confirmation before proceeding with the rm
Just to be very clear i need to generate a log file in which the file name should be there before deleting the files which are two days older .. can anyone can help me on this .. Thanks in advance !!
i am using this command find * -type f -atime +30 -exec gunzip {} \; for unzipping the files which are 30 days older .. but how can i get the log for which files the command has unzipped ..