Evil Filenames

Filenames should be kept simple in order to eliminate problems caused when they are shared with users of different types of operating systems.

Proper filenames should avoid the following situations:

Other formatting foolishness should be avoided such as starting filenames with a hyphen '-' as their presence can confuse many scripting environments.

Consider how one might remove a file whose name is any one of:

*
~
!$
-rf *
-rf ~
-rf ~&

Removal of an Evil Filename on Unix/Linux

If you create or otherwise acquire a file with a problematic name, you can carefully remove it with the rm command by safely escaping the special characters. For example, to remove a file whose name is: -rf * you can safely remove it with the following command. (Yes, including the backslash.)

\rm -i -- '-rf *'

See rm(1) for details on the -i and -- options.

Last modified: 2021-01-05 17:01:47 CST