Support Forums

Full Version: [UNSOLVES] find [Bash]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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?