How Can I Delete a Folder Named ‘-p’?

0
6
Asked By RustyNail83 On

I accidentally created a folder named '-p' using the mkdir command on my Ubuntu 24. Now, I can't seem to delete it. The name appears as '–p', and when I try to remove it, I get stuck because of the leading dash. Any ideas on how to get rid of this folder?

3 Answers

Answered By LinuxLover42 On

Another option is to use `rmdir -- -p`. The double dash tells the command that everything following it is a folder name, not an option. If that fails, you might have some hidden characters causing issues. Use tab completion to check if the name expands correctly.

Answered By OldSchoolLinuxer On

If all else fails, booting from a live USB with a lightweight Linux distro like Puppy Linux is a good way to access your files and delete the folder directly.

Answered By CodeMaster7 On

If you can't remove it with the usual commands, check the inode number with `ls -i` and then try deleting it using the inode with `find . -inum -exec rm {} ;`. This can bypass naming issues.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.