DEV Community

Discussion on: Deleting files that start with a hyphen in Bash

Collapse
 
makhauser profile image
mkh

Just in case you can always find the file by its inode and remove it. But these variants are faster of course.

Just in case:

$ ls -i
$ find . -inum $INODE -exec rm -i {} \;

Collapse
 
_morgan_adams_ profile image
morgana

Nice one!

I'm going to work that into my post and credit you with that one if that's okay.

I knew you could use ls to see inode info, but I didn't know you could use inode info with find.

Collapse
 
makhauser profile image
mkh

Sure you can, but that is an old instruction, don't even remember where I have found it. Most likely on the Cybercity. What is good in this trick - you can delete the file with any naming issues either it has slashes, dashes or whatever.