Is semicolon (;) allowed in filenames?

Is the character "; " allowed in the filename? In windows you can use the character" ; " in the naming of files without any problem, but I do not know if the same rule fits for Mac or Linux. I researched about file naming, and found several topics talking about other characters, however, I found nothing talking about " ;".

Author: SUR1C4T3, 2018-08-15

2 answers

In principle, it can, but if it is to use by command line, it needs "escape" or quotation marks in Unix. Although accepted in the filename, in the Shell it has a special meaning, it separates the commands. In Windows it is accepted without restrictions.

As a complement, the English Wikipedia has a very good compendium of information about filenames:

Article: Filename.


in particular, I translated this table that lists the characters considered special in the most common (and not so many) filesystems:

 /     barra            Usada como separador de caminho em sistemas Unix-like,
                        Windows e Amiga (a variável SwitchChar do DOS pode ser
                        setada para '/' e o COMMAND.COM considerará como indicador
                        de flag, mas o DOS e o Windows mesmos aceitam como
                        separador na API)

 \     barra invertida  Usada como separador padrão no DOS, OS/2 e Windows (mesmo
                        com SwitChar configurado para '-'; é aceito em nomes Unix)

 ?     interrogação     É usado como coringa em Unix, Windows, Amiga, e representa
                        um caractere único. É permitido em nomes Unix

 %     porcentagem      É um coringa em RT-11, define um caractere único. Em Windows
                        pode ser usado

 *     asterisco        Usado como coringa em Unix, DOS, RT-11, VMS e Windows.
                        Representa uma sequência de caracteres em Unix, Windows, DOS,
                        ou qualquer sequência na extensão (*.* significa "todos os
                        arquivos"). Em Unix, pode ser usado nos nomes de arquivo

 :     dois pontos      Serve para determinar o ponto de montagem no Windows, o
                        dispositivo virtual ou físico no Amiga, RT-11 e VMS e é o
                        separador de caminho no MacOS Clássico. No VMS, indica um
                        nome de nó DECnet quando usado em dobro (equivale a um endereço
                        NetBios. No Windows ainda é usado para separar um Data Stream
                        do nome de arquivo em NTFS

 |     barra vertical   Define um redirecionamento de software em Unix, DOS e Windows;
        ou pipe          Permitido em nomes Unix

 "     aspas duplas     Usadas para delimitar nomes com espaços em Windows

 <     menor que        Usado para redirecionar entrada, permitido em Unix

 >     maior que        Usado para redirecionar saída, permitido em Unix

 .     ponto            Permitido, mas a última ocorrência indica separador de extensão
                        em VMS, DOS, e Windows. Em outros sistemas, normalmente faz parte
                        do nome, e pode ter mais de uma ocorrência seguida. Normalmente, em
                        Unix indica que o nome deve ser escondido da listagem

       espaço           É permitido, mas como também é um separador de parâmetros de linha
                        de comando, deve-se delimitar o nome com aspas para diferenciar dos
                        parâmetros

Important: in Unix, although accepted, characters <>|\:()&;#?* typically need to be "escaped" with backslash, or delimited with command line quotes:

Ex: five\ and\ six\<seven or even "five and six<seven".


considerations:

Just because you can use certain characters doesn't mean you should use them. The recommendation is to use "less" characters common " only where there is a reason that cannot be circumvented by other means, such as standardization and sanitization.

Thinking of interoperability, even using allowed characters, the simple mixing of uppercase and lowercase is a very common problem when exchanging files between different OSes, since in Windows there is no differentiation, and in considerable parde of the other OSes there is. As the use of special characters also varies, a lot of headache is avoided by limiting yourself to one simplified nomenclature (staying in the range a-z0-9_. for example is a good request).

Accentuation and formatting make sense for things handled only by the end user (cake recipe, cover letter, washing machine finance installment sheet, those things), but files that must be processed by a system deserve greater care. Personally, I find it a crime to do as I see a lot here on the site, to make a point of keeping original names in upload file, when it would be much simpler to store the names in the DB and simply put a sequential string in the filesystem.

 4
Author: Bacco, 2018-08-15 12:10:25

In both cases, linux and mac, only the characters / and \0 (null) are fully blocked, all the others can be used, although not recommended.

If you create a semicolon file, or other unconventional character, you will need a escape to access the file manually.

Example:

Meu;arquivo.txt

To read:

cat Meu\;arquivo.txt

Even allowing almost all characters, to avoid access problems it is recommended to use only the following:

  • a-z
  • A-Z
  • 0-9
  • underline (_)
  • dash ( - )
  • point (.)

Another more extreme example:

'"!@#$%&*()-_+=[{]}~^?;:><,..txt

How to access:

cat \'\"\!@#\$%\&\*\(\)-_+\=\[\{\]\}~\^\?\;\:\>\<\,..txt
 3
Author: res, 2018-08-15 11:13:19