Reputation: 43
I am having some issues deleting some folders in unix.
Directory 1:
?0\'
Directory 2:
-1\'
I would like to delete them recursively so something like
rm -rf -1\'
Not sure on how to escape the quotes, dashes and question marks.
Upvotes: 0
Views: 578
Reputation: 755044
Be careful; check carefully before you execute any rm -fr
on weird directory names.
The standard trick for file names (directory names) starting with a dash -
is to prefix the name with ./
so that it doesn't start with -
any more:
rm -fr ./-1??
The other directory could perhaps be identified by:
rm -fr ./?0??
I would, at the very least, run:
echo ./-1?? ./?0??
before trying the rm
commands, to ensure that only the correct directories are picked up. The rm
command is dangerous if you're not certain that it is doing what you want.
The notation using questions marks avoids having to quote the question marks, backslashes and single quotes, in part out of a suspicion that what shows on the terminal may not be the name in the file system. You may need to do further work to identify the names, such ls | od -c
or similar commands to validate the exact spelling of the directory names.
Upvotes: 0
Reputation: 574
You need to use quotes when they are fishy characters, then use a wildcard outside of the quotes. Without quotes those characters would want to preform other tasks.
rm -rf -- *"\'"
Thanks to a comment by osgx
Upvotes: 1