For a programming challenge I need a filesystem which supports newline characters in filenames, so a file can be named something like:


I can't find any. Can anyone help me?

  • 2
    I can think of nothing but problems with this. How would you access the file over a CLI? A\nfilename...? Icky! – Phoshi Apr 10 '10 at 13:56
  • 5
    The only bytes most Unix file systems do NOT allow in file names are slash (/), which separates directory and file names in a path, and NULL (\000), which indicates the end of the name. You can get interesting problems, though, with various programs that are not expecting nonprinting characters like backspace in a file name. – mpez0 Apr 10 '10 at 15:17
  • 2
    Mac OS X supports slashes as part of the file name in the GUI, but it does it by translating them into colons when converting from the traditional Mac paths. Colons on the other hand, which Macs traditionally use to separate path components get translated to slashes. A folder called 27/January on a disk called External would appear as External:27/January in the GUI, but that gets converted into the POSIX path /Volumes/External/27:January – Andrew Turner Dec 25 '11 at 21:01
  • 1
    For the record, some graphical file managers (at least Dolphin on Linux) allow to use slashes in file names and silently translate it into the UTF-8 symbol (0xe28184) instead of the ASCII / (0x2f). – WhiteWinterWolf Mar 22 '17 at 9:40
  • most Unix filesystems allow newlines in filenames. See en.wikipedia.org/wiki/Comparison_of_file_systems. That's the reason why one shouldn't parse the result of ls – phuclv Dec 24 '17 at 12:49

Most Unix file systems allow for this. But you will often run into trouble with various programs and scripts that won't know how to handle it. If you do

date > 'test-
ls -lbd test*

Then you will see a \n in the file name which is a newline.

  • 3
    When Steve Bourne was testing his shell, he had a directory with 254 single-character file names in it - and it wrought havoc on programs that were not expecting such characters in file names. – Jonathan Leffler Apr 11 '10 at 4:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.