Cannot remove directory with spaces in its name

dradovsky

Cadet
Joined
Dec 23, 2013
Messages
9
I am trying to remove a directory and its contents with the rm -rf command but it's not working. I don't get an error message, just a ">" symbol on the next line. Eventually, I have to use ctrl-c to escape.I am thinking that the problem may be that it is a Time Machine backup that has spaces, an apostrophe, and a period in its name. If that is the case, any solutions?

Thanks
 

Fredda

Guru
Joined
Jul 9, 2019
Messages
608
If your directory is named e.g. "with spaces in it" you could try to remove it via wildcards rm -rf *spaces*, but make sure that does not match other directories.

Or start the midnight commander (command mc in the shell), navigate to the directory and delete from there.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
or escape the spaces with the backslash... rm -rf directory\ With\ Spaces\ in (which is what the system will help you to do if you type the first part and hit tab... rm -rf directory <-- TAB )
 

dradovsky

Cadet
Joined
Dec 23, 2013
Messages
9
Fredda, thanks. I'm using Midnight Commander and it's working. Never knew there was such a thing. Easy peasy.
 
Top