Is the dot and comma character (;) allowed in filenames?

Asked

Viewed 1,270 times

0

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

  • 1

    https://answall.com/questions/184020/por-que-em-filenames-and-pastures somethings-characters-ainda-n%C3%a3o-s%C3%a3o-accepted

2 answers

4


In principle, you can, but if you’re going to use it by command line, you need "escape" or Unix quotes. Although accepted in the filename, in Shell it has a special meaning, it separates the commands. In Windows it is accepted without restrictions.

As a complement, Wikipedia in English has a very good compendium of information about file names:

Article: Filename.


In particular, I translated this table which lists the characters considered special in filesystems more common (and others not so much):

 /     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 <>|\:()&;#?* usually need to be "escapes" with backslash, or delimited with command line quotes:

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


Considerations:

The simple fact that you can use certain characters does not mean you should use them. The recommendation is to use "less common" characters only where there is a reason that cannot be circumvented by other means, such as standardization and sanitization.

Thinking about interoperability, even using permissible characters, the simple mix of upper and lower case is a very common problem when exchanging files between different Oses, because in Windows there is no differentiation, and in considerable parde of the other Oses there are. As the use of special characters also varies, it avoids a lot of headache if limited to a simplified nomenclature (stay in the range a-z0-9_. for example is a good request).

Accentuation and formatting make sense for things manipulated only by the end user (cake recipe, presentation letter, spreadsheet of installments of the financing of the washing machine, these 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 sure to keep original names in file upload, when it would be much simpler to store the names in DB and simply put a sequential string in the filesystem.

  • I found this table on other forums and as there was nothing saying ";" I was in doubt... Your answer surely cleared my doubt, but now a problem has arisen for min... I am saving a log file with the following format "day-month-year hour;second;" will there be another "beautiful" way to save it?

  • 1

    At the very least reverse the positions, because the way you exemplified everything is out of order. I usually use it like this: 20180816_084117 without much freshness (year, month, day, minute second hour). Do not need to despise the user to the point of thinking that he will not understand. If you really want to break up, you can do something like 2018-08-16.08h42m31 or even 2018-08-16_08.42.31 - in this order 2017 thing will stick with thing 2017, January with January, ordered per day. If I reverse the positions, it’ll be one from January to February, then back to January 2, and mixing the year to make it worse.

  • I was using 2018-08-16 08;42;31 but I found this tip "2018-08-16.08h42m31" very cool! I will implement soon. But a doubt this point '.' that has there will not interfere in anything in the file extension right?

  • @Eduardomior what defines the extension (which is a practically exclusive thing of Windows, because in the other Oses does not mean anything, it is only part of the name) is the last point. A file aaa.bbb.ccc.ddd.eeefor Windows is aaa.bbb.ccc.ddd extended eee. If the extension is important, add one after the time (even for windows do not hide the time on the desktop). Examples: 2018-08-16.08h42m31.txt, 2018-08-16.08h42m31.log, etc.

  • thank you very much for the explanation, now yes this all solved.

3

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

If you create a semicolon file, or another 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 (_)
  • trait (-)
  • dot (.)

Another more extreme example:

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

How to access:

cat \'\"\!@#\$%\&\*\(\)-_+\=\[\{\]\}~\^\?\;\:\>\<\,..txt
  • Both your answer and that of Bacco solved my question but now I have another problem... I am saving a log file with the following format "day-month-year hour;minute;second" will be that there is another "beautiful" way of

Browser other questions tagged

You are not signed in. Login or sign up in order to post.