Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[UNSOLVES] find [Bash]
#1
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  .Bashrc (Bash) Scorpion 1 790 01-15-2010, 05:26 PM
Last Post: Salmon
  Bash Scripting Tutorial bsdpunk 1 1,060 10-23-2009, 10:05 AM
Last Post: Gaijin

Forum Jump:


Users browsing this thread: 2 Guest(s)