# Removing Infinitely Nested Directories

Let me start off by claiming this is a Mac Terminal I'm making use of. Not Linux, yet I thought I would certainly get the most effective solutions below as it concerns Unix and also the command line not actually anything concerning Mac itself.

Anyways below is the trouble. In an effort to be exceptionally careless, I attempted to write a function in my ~/. bashrc that would certainly allow me relocate right into a "homework" folder, developed a folder with today is day, relocate right into claimed folder, and also open strength with the offered filename done in one go. It looked something like

export DATE="$( date +%d-%b )" function hw() { cd ~/Java/Programs/HW mkcd$DATE
vim "\$*"
}


mkcd is a function that makes the folder and also relocates right into it at the very same time. This is what my function resembles currently and also it functions simply great. Nonetheless know of my several efforts to make this job I made an actually actually foolish mistake and also wound up with some sort of boundless loop with my mkcd component still not exactly sure just how I handled this and also I've given that removed that code. Well what took place when I did this is fairly noticeable I currently have actually a folder called 27 - Jan that has definitely several folders called 27 - Jan within it. (Like I claimed actually foolish)

Well to make it stop placing me much deeper and also much deeper I struck ^ c and also viola I quit I transformed back to my ~/ folder and also did a fast sudo rm 27-Jan/. To my awe (and also fear) that really did not function. I attempted a for even more points to remove it yet absolutely nothing did anything. So being brilliant like I am I relocate to.Trash and also quit bothering with it. Ever since I have actually cleared my garbage a couple of times and also never ever actually seen yet that bloody folder will not vanish! It is occupying absolutely no bytes on my hard drive yet it is still there with all it is little below folders.

What I've Tried:

sudo rm 27-Jan/
sudo rm -r 27-Jan/


This one claimed override rwxr-xr-x caldwell/staff for 27-Jan/(many times repeated)/27-Jan? To which I've reacted y and also yes and also also si (in instance it talked spanish) everytime it claims No such file or directory and also repeats the previous inquiry.

Has any person ever before seen anything similar to this? And also do you recognize what I could be able to do to make it simply vanish?

6
2022-06-07 14:40:19
Source Share

You can remove directory power structures recursively making use of - r button of rm

-r, -R, --recursive
remove directories and their contents recursively


So releasing

rm -r 27-Jan


needs to remove the directory. Unless you have actually currently attempted that, certainly. Because instance, could you define the mistake you get?

3
2022-06-07 15:11:36
Source

Try rm -rf to stay clear of the motivating.

-f, --force           ignore non-existent files, never prompt

8
2022-06-07 15:11:31
Source

A really safe and secure means would certainly be - if your find assistances - delete - to make use of find for removing:

find -type d -name 27-Jan -empty -delete


Since -delete indicates -depth, it will certainly first stroll down the tree to directory 3275, delete it, tip up one action, currently 3274 is vacant also, and also can be removed, tip up to 3273 and more

male find:

   -depth Process each directory's contents before the directory itself.
The -delete action also implies -depth.

4
2022-06-07 15:11:25
Source