Support Forums
[UNSOLVES] find [Bash] - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Computer Support Topics (https://www.supportforums.net/forumdisplay.php?fid=4)
+---- Forum: Linux, FreeBSD, and Unix (https://www.supportforums.net/forumdisplay.php?fid=17)
+---- Thread: [UNSOLVES] find [Bash] (/showthread.php?tid=24636)



[UNSOLVES] find [Bash] - i586 - 01-16-2012

Need to find all empty files and folders in current category, show their creation date and time, and delete them.
For finding and deleting I tried using:
Code:
find . -maxdepth 1 -type d -empty -exec rmdir {} \;
Same with files:
Code:
find . -maxdepth 1 -type f -empty -exec rm ;
But how with their names? Tried to use:
Code:
find . -maxdepth 1 -type d -empty;
find . -maxdepth 1 -type d -empty -exec rmdir {} \;
But this gives only directories. Then i used this code:
Quote:find . -maxdepth 1 -type d -empty -exec ls -l;
find . -maxdepth 1 -type d -empty -exec rmdir {} \;
But it gives plenty more information.. Creation date is not saved on UNIX,
so I think date then file was last modified would better to write.. But how?
I can find for example files that were modified certain time ago..
Code:
find . -mtime -1 -print

But how to put it all together? What script would search current dirrectory for empty files and folders, delete them and show names and date (creation/edition) of those deleted files?
Any ideas?