Monday, May 16, 2011

HOWTO: delete/rename files with special characters (! ~ %) on the linux commandline

Sometimes you (or your code) screws up and you end up with a filename that is hard to address on the filename because it has special characters in its name. In some cases you can get away with prepending a ./ or quoting, or escaping with backslash. When those don't work, this can get you out of trouble.

First, grab the file or directory's inode:
ls -lhi
Then use the find command with the inode of the troublemaker:
find . -type f -inum 25167125 -exec mv {} binary_safe \;

1 comment:

Anonymous said...

awesome!