Should all plain text files have some sort of suffix (e.g. *.txt, *.conf)

5

I create many notes in plain text files, but after a while the .txt suffix I put at the end of them seems to be unnecessary typing and visual noise. Is appending .txt to plain text files a strongly encouraged convention or just a suggestion?

dan

Posted 2011-05-13T13:20:02.833

Reputation: 5 307

Answers

10

The .txt filename extension serves a purpose on Windows, where the filename extension helps determine which programs are associated with that file - which one is used to open, edit or perform other types of action on it.

On Unix/GNU-Linux, the system works out the type of a file without referring to the filename extension. It does have some uses in Makefiles. [update:] As grawity noted in a comment below, the filename extension is used by Linux file-managers (I assume this means GUI apps like nautilus and character apps like mc).

However I find it a useful convention to adhere to anyway.

RedGrittyBrick

Posted 2011-05-13T13:20:02.833

Reputation: 70 632

Most file managers for Linux do use the file extensions, as it's the only method with reasonable performance. – user1686 – 2011-05-13T13:45:41.117

@grawity: Ah right - I don't use file manglers on Linux (GUI, CUI, TUI or otherwise) – RedGrittyBrick – 2011-05-13T13:49:52.283

In windows, you can hide known file extensions. If you are using notepad for notes, it will automatically append the .txt extension to the end. – Doltknuckle – 2011-05-13T15:21:27.470

It's especially useful to adhere to an editor's default file extensions for Open/Save dialogs, if possible. Some Windows Open File dialogs will filter out all non-conforming files and you need to explicitly select All file types or something like that first. Inconvenient. – Daniel Beck – 2011-05-13T16:31:15.220

In the strictest sense, OS X allows you to avoid using file extensions if you want to, but using them enables you to influence the way the OS treats the file. Most of the time, OS X can attempt to guess what the filetype is, but the convention doesn't hurt. You can hide the extensions anyway if you want. :) – Lukasa – 2011-05-13T16:59:02.627

1

Nothing more then convention, IMO.

I almost never use file extensions (in Windows) for text files. In general, I always know what is in my files, & generally always open files from within a file manager, either to view (happens to be F3) or to edit (happens to be F4) or from a context menu (to open in Vim).

The only odd time that I add an extension, is if I know the for a particular file I'll specifically want to open in something that I normally do not use (like Notepad) in which case I'll append an extension (like .doc) to the filename so that it will open in the default application (Notepad, for me).

If you want to perform an action on a set of files (as mentioned above) & if having an extension such as .txt helps, then I would do something like that for that set. (I do something similar, though instead of an extension, I have numerically numbered sets of files, so I can select 7* to get all the files that start with the number 7, to process them further.)

therube

Posted 2011-05-13T13:20:02.833

Reputation: 1 296

0

Assuming you are on Windows - if you don't put a file extension on, then it won't automatically open when you double click it. It is certainly "strongly encouraged."

James

Posted 2011-05-13T13:20:02.833

Reputation: 103

0

Under Unix, it is useful to perform operations that are restricted to just textfiles. For instance

ls *.txt

will show you just the text files, while

find . -name \*.txt -exec grep foo -H {} +

will search for foo in all of the text files under the current directory. Even if you don't do this often, it is useful occasionally.

KeithB

Posted 2011-05-13T13:20:02.833

Reputation: 8 506