[arm-allstar] File extensions and audio format
Willem Schreuder
willem at prinmath.com
Thu Feb 11 12:14:48 EST 2016
On Thu, 11 Feb 2016, Chris Zenchenko wrote:
> Why in some cases do they have extensions and in others they don't?
> Should they all have extensions?
I'll weigh in on this part of question:
File extensions on Unix/Linux systems typically do not matter. In a few
instances like C programs, the .c is used by the compiler to distinguish
foo.c from foo.o (source code versus object code), but that is a naming
convention and is not actually inherent in defining the file.
Executable programs on Linux/Unix systems are defined by their "magic".
For scripts, it is typically the first line in the file, e.g.
#!/usr/bin/perl
or
#!/usr/bin/python
The shell will look at that line and if it is present, it will invoke the
perl or python interpreter to run the file. Since the # makes it a
comment for the interpreter it is ignored. In Unix speak this is called a
"shebang line" (hash + bang, and ok yes we have a strange sense of humor)
Using a .py and .pl file extension makes it obvious that it is actually a
python or Perl script, but that is for the user only. Unlike Windows, the
OS attaches no special meaning to the .py and .pl extension.
The same thing is true for shell scripts. You can add
#!/bin/bash
to the beginning of the file and invoke the bash shell explicitly, or if
you omit that the script gets processed by whatever shell you use. On
Linux systems the bash shell is pretty much universally used.
The .sh extension is a clue to the user, but has no special meaning to the
OS.
I personally tend to omit .pl, .py, .sh and so on. The language in which
a command or shell script is written only matters if you want to change
it. The only time I would use an extension is if I need to distinguish
say a system command foo and a shell script foo.sh which invokes that
command with a special set of parameters, or something of that nature. In
those cases, however, I tend to use the case sensitivity. So foo is the
command and Foo is a shell script that runs foo in some special way. But
that's just me.
If you want to see what a command is (i.e. script, executable, etc) you
can use the 'file" command. Doing
file foo
tells you more about what kind of file it is. It uses the signatures in
the /etc/magic file to figure out the file type based on its contents
rather than the name of the file. It makes an interesting read.
73 Willem AC0KQ
================================================================
Dr. Willem A. Schreuder, President, Principia Mathematica
Address: 445 Union Blvd, Suite 230, Lakewood, CO 80228, USA
Tel: (303) 716-3573 Fax: (303) 716-3575
WWW: www.prinmath.com Email: Willem.Schreuder at prinmath.com
More information about the arm-allstar
mailing list