Issue
I have many EC2 instances in a folder that I need to delete. Using -delete
doesn't work because the directories are not empty. I tried looking for a way to get -rmdir -f to work with no success. The instance folders are all started with "i-"
which led me to add wildcard "i-*"
like that to get it to delete all directories starting with those characters. How can I manage to do this? the directories will never be empty either.
Solution
Assuming your current dir is the folder in question, how about:
find . -type d -name 'i-*'
If that lists the directories you want to remove, then change it to:
find . -type d -name 'i-*' -exec rm -r {} \;
Answered By - stark Answer Checked By - Gilberto Lyons (WPSolving Admin)