Quick tip: Delete or rename files with leading dash (-)

I was restoring some files from backup today and ran into a few files that had leading slashes. Whenever I see those kind of things I rename the files since they are a pain to work with in the shell.

If you find yourself at a shell and need to work with files that have a leading dash just use the relative path and include the dashed filename in quotes.

mv ./"-somefile.txt" ./somefile.txt

5 Comments

Leave a Reply

Your email is never shared.Required fields are marked *

To submit your comment, click the image below where it asks you to...
Clickcha - The One-Click Captcha