Ubuntu and Unix systems in general use magic numbers to specify a file's type, so that e.g. VLC will open a .mp4
file even if the extension is stripped from the file name. However in scripts the Shebang serves the very same purpose.
Why don't we have individual magic numbers for bash
, perl
, sed
, awk
, … scripts as well?
All scripts like bash, perl or sed are using the format ASCII text while mp4 are read as binary. Having different file header at binary level and dependant of the language while the content remain a text doesn't make sense as that means having specific software for opening each file type. Having a simple declaration in the file is enough and ensures that the script can be opened in any text editor.