How to Include a Forward Slash in a File Name

filenamefiles

I understand that this will likely break and confuse the hell out of my system, but is it possible to name or rename a file so that it has /s in its name (this is needed for a file which needs to go to an equally crazy server – well, sort of, it's more of a crazy workaround)? I am running Ubuntu GNOME 15.10 with GNOME 3.18, and I have tried to do this with most programs, and they either make a folder with the file because they treat what is before the / as the folder and what is after it as the file name, or just give me an error.

Reason:

The specific reason why I need it is because I set up a server which is stubborn and now won't change it's mind about where its config file is. However I accidentally put a / in the name of the file so it believes that the config file rather being in ~/configuration/files/config1.conf is in ~/configuration/files/con/fig1.conf… So you might say that I should just create a folder in files and call it con and then have the config file called fig1.conf, however the server doesn't even currently allow the creation of new directories or anything really… So I think that my only hope is going to be to put the forward slash in the file name for now until it goes out of its lock down mode.

Best Answer

Is it possible to name or rename a file so that it has /s in its name [...]?

No, it's not, for obvious reasons.

E.g. consider you have a directory containing:

  • a directory named "foo" containing a file named "bar"
  • a file named "foo/bar"
/path/to/foo/bar # file named "bar" in the directory named "foo"
/path/to/foo/bar # file named "foo/bar"

Referencing either of the two would be ambiguous.

If you're curious as to where the limitation is imposed, that's at the kernel level, in order to comply with the filesystem's specifications.

In general, any character can be used in a filename aside from / (unicode 002f) and \0 (unicode 0000), and filenames such as . and .. are disallowed as well.

Related Question