Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
-
The problem statement, all variables and given/known data:
Need to make a script, to remove all empty files and folders from current category.
It also should show the name and creation date of those items. -
Relevant commands, code, scripts, algorithms:
Must be bash script. -
The attempts at a solution (include all code and scripts):
Tried this, but it shows only name of deleted folders...
echo Removed files:
find . -maxdepth 1 -type f -empty;
find . -maxdepth 1 -type f -empty -exec rm {} \;
echo Removed directories:
find . -maxdepth 1 -type d -empty;
find . -maxdepth 1 -type d -empty -exec rmdir {} \;
Then I tried using
ls
... But it gave too much information.. I just need name and creation time (Ok.. Creation time isn't stored in UNIX.. So I think a date of last modification would be enough.. )
echo Removed files:
find . -maxdepth 1 -type f -empty -exec ls -l;
find . -maxdepth 1 -type f -empty -exec rm {} \;
echo Removed directories:
find . -maxdepth 1 -type d -empty -exec ls -l ;
find . -maxdepth 1 -type d -empty -exec rmdir {} \;
But in this code first of all it shows only info about files.. For some reason it doesn't show anything about folders. And secondly: That's not that I need. I need name and date (maybe date, maybe date+time) of creation (last modification).
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Vilniaus Kolegija, Vilnius, Lithuania, M.Liogys, PIN11.
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).