9

Which characters are invalid for an ext3 filename? I imagine that at least / is an invalid character and probably \0. Is there an official list somewhere?

I'm not exactly sure where to look for this information, so please tell me where you found it.

User1
  • 2,386
  • 4
  • 19
  • 21
  • An interesting, albeit lengthy, read: [Fixing Unix/Linux/POSIX Filenames](http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html). – Dennis Williamson Dec 01 '10 at 22:41

2 Answers2

9

Just those two.

From the wikipedia page on ext3:

Allowed characters in filenames - All bytes except NULL and '/'

mark
  • 2,325
  • 14
  • 10
3

/ seems to be allowed, at least on ext3 (supposedly in all, ext, ext2 & ext3 at least, likely also ext4) - just try this:

f='test/file'; echo "Test: '${f}'"
for c in touch ll rm ;do
eval "${c} '${f}'"
done

That will create "test/file", surprised me too... It will create it, show it with ls command and finally remove it with rm

You can type it on one line in bash:

$ f='test/file';for c in touch ll rm ;do eval "${c} '${f}'";done

So / seems to be (bizerrely) allowed in filenames - probably many tools can get confused with such though...

robsku
  • 39
  • 4
  • Cool trick, though probably ill-advised on production systems :-) – voretaq7 Oct 19 '12 at 18:58
  • Errr… do you have a directory called 'test'? That'll make a difference: `touch: cannot touch 'test/file': No such file or directory` – MikeyB Oct 19 '12 at 19:35
  • Though useful as a joke to pull on one's assistants. – Magellan Oct 19 '12 at 20:05
  • No just managed to create a file named "test/file" - would be interesting to try it with existing directory named test... It might not even give trouble, after all, the / at the end of directory name isn't really part of it's name... So I could imagine them actually working together... It'll look confusing though... Or did you mean you actually tried it? :) – robsku Jul 22 '14 at 13:10