is a microblog
home archives search feed blogroll

Delete Files With Special Character Names

There are some files that cannot be deleted with the regular rm command.

Try running this command to create a file named \.

touch \\

Now try to delete it with rm. You can’t.

What you need to do in those special cases is use the inode number. Run ls -il to retrieve the inode number of the file named \. It’s the number in the first column. Then run the following command.

find . -inum [inode_number] -exec rm -i {} \;

There’s a confirmation. Type Y. The file is now gone.

Posted on 2018-02-11   #bash     #til  

← Next post    ·    Previous post →