Why is the first field in 'ls - l' not a 'f' when viewing a file? [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
7
down vote

favorite












When I do 'ls -l', I might get something like this:



-rw-r--r-- 1 root root 209 Mar 30 17:41 fname



The first field is the -, which means this is a file.



If it was a directory and not a file, the first field would be a d.



Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?



Edit

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.










share|improve this question















closed as primarily opinion-based by Jeff Schaller, telcoM, Goro, RalfFriedl, muru Sep 24 at 15:34


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
    – Sergiy Kolodyazhnyy
    Sep 22 at 19:49











  • Wow, thanks for the links. Reading now.
    – Monica Heddneck
    Sep 22 at 19:50










  • Let me know if you have any questions or any parts of the answers need clarification.
    – Sergiy Kolodyazhnyy
    Sep 22 at 19:51






  • 2




    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – Wumpus Q. Wumbley
    Sep 22 at 19:57










  • Understanding UNIX permissions and file types might be relevant here.
    – Stephen Kitt
    Sep 22 at 20:21














up vote
7
down vote

favorite












When I do 'ls -l', I might get something like this:



-rw-r--r-- 1 root root 209 Mar 30 17:41 fname



The first field is the -, which means this is a file.



If it was a directory and not a file, the first field would be a d.



Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?



Edit

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.










share|improve this question















closed as primarily opinion-based by Jeff Schaller, telcoM, Goro, RalfFriedl, muru Sep 24 at 15:34


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 1




    Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
    – Sergiy Kolodyazhnyy
    Sep 22 at 19:49











  • Wow, thanks for the links. Reading now.
    – Monica Heddneck
    Sep 22 at 19:50










  • Let me know if you have any questions or any parts of the answers need clarification.
    – Sergiy Kolodyazhnyy
    Sep 22 at 19:51






  • 2




    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – Wumpus Q. Wumbley
    Sep 22 at 19:57










  • Understanding UNIX permissions and file types might be relevant here.
    – Stephen Kitt
    Sep 22 at 20:21












up vote
7
down vote

favorite









up vote
7
down vote

favorite











When I do 'ls -l', I might get something like this:



-rw-r--r-- 1 root root 209 Mar 30 17:41 fname



The first field is the -, which means this is a file.



If it was a directory and not a file, the first field would be a d.



Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?



Edit

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.










share|improve this question















When I do 'ls -l', I might get something like this:



-rw-r--r-- 1 root root 209 Mar 30 17:41 fname



The first field is the -, which means this is a file.



If it was a directory and not a file, the first field would be a d.



Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?



Edit

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.







terminal ls






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 22 at 20:07

























asked Sep 22 at 19:36









Monica Heddneck

1363




1363




closed as primarily opinion-based by Jeff Schaller, telcoM, Goro, RalfFriedl, muru Sep 24 at 15:34


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as primarily opinion-based by Jeff Schaller, telcoM, Goro, RalfFriedl, muru Sep 24 at 15:34


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 1




    Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
    – Sergiy Kolodyazhnyy
    Sep 22 at 19:49











  • Wow, thanks for the links. Reading now.
    – Monica Heddneck
    Sep 22 at 19:50










  • Let me know if you have any questions or any parts of the answers need clarification.
    – Sergiy Kolodyazhnyy
    Sep 22 at 19:51






  • 2




    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – Wumpus Q. Wumbley
    Sep 22 at 19:57










  • Understanding UNIX permissions and file types might be relevant here.
    – Stephen Kitt
    Sep 22 at 20:21












  • 1




    Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
    – Sergiy Kolodyazhnyy
    Sep 22 at 19:49











  • Wow, thanks for the links. Reading now.
    – Monica Heddneck
    Sep 22 at 19:50










  • Let me know if you have any questions or any parts of the answers need clarification.
    – Sergiy Kolodyazhnyy
    Sep 22 at 19:51






  • 2




    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – Wumpus Q. Wumbley
    Sep 22 at 19:57










  • Understanding UNIX permissions and file types might be relevant here.
    – Stephen Kitt
    Sep 22 at 20:21







1




1




Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
– Sergiy Kolodyazhnyy
Sep 22 at 19:49





Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic.
– Sergiy Kolodyazhnyy
Sep 22 at 19:49













Wow, thanks for the links. Reading now.
– Monica Heddneck
Sep 22 at 19:50




Wow, thanks for the links. Reading now.
– Monica Heddneck
Sep 22 at 19:50












Let me know if you have any questions or any parts of the answers need clarification.
– Sergiy Kolodyazhnyy
Sep 22 at 19:51




Let me know if you have any questions or any parts of the answers need clarification.
– Sergiy Kolodyazhnyy
Sep 22 at 19:51




2




2




If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
– Wumpus Q. Wumbley
Sep 22 at 19:57




If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
– Wumpus Q. Wumbley
Sep 22 at 19:57












Understanding UNIX permissions and file types might be relevant here.
– Stephen Kitt
Sep 22 at 20:21




Understanding UNIX permissions and file types might be relevant here.
– Stephen Kitt
Sep 22 at 20:21










1 Answer
1






active

oldest

votes

















up vote
11
down vote













Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.






share|improve this answer






















  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    Sep 22 at 20:17










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    Sep 22 at 20:20






  • 4




    @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    Sep 22 at 20:31







  • 2




    @Sergiy, no, there is no header. There are heuristics to try to guess a file’s type but there is no guaranteed header, or magic number, etc. All sorts of fun and games can be had by abusing those guesses.
    – Stephen Kitt
    Sep 22 at 20:34







  • 2




    @Sergiy I know what you’re trying to convey, but in my experience it’s too simplistic and it ends up confusing users. file, and the shared MIME database, apply a sequence of detection tests, some of which look at the first few bytes of a file. But claiming that the first few bytes of a file give an indication of its type gives readers the wrong impression. There is no guaranteed way of determining a file type (unlike Mac OS Classic or PalmOS where each file had a type and creator code).
    – Stephen Kitt
    Sep 22 at 20:47

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
11
down vote













Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.






share|improve this answer






















  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    Sep 22 at 20:17










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    Sep 22 at 20:20






  • 4




    @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    Sep 22 at 20:31







  • 2




    @Sergiy, no, there is no header. There are heuristics to try to guess a file’s type but there is no guaranteed header, or magic number, etc. All sorts of fun and games can be had by abusing those guesses.
    – Stephen Kitt
    Sep 22 at 20:34







  • 2




    @Sergiy I know what you’re trying to convey, but in my experience it’s too simplistic and it ends up confusing users. file, and the shared MIME database, apply a sequence of detection tests, some of which look at the first few bytes of a file. But claiming that the first few bytes of a file give an indication of its type gives readers the wrong impression. There is no guaranteed way of determining a file type (unlike Mac OS Classic or PalmOS where each file had a type and creator code).
    – Stephen Kitt
    Sep 22 at 20:47














up vote
11
down vote













Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.






share|improve this answer






















  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    Sep 22 at 20:17










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    Sep 22 at 20:20






  • 4




    @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    Sep 22 at 20:31







  • 2




    @Sergiy, no, there is no header. There are heuristics to try to guess a file’s type but there is no guaranteed header, or magic number, etc. All sorts of fun and games can be had by abusing those guesses.
    – Stephen Kitt
    Sep 22 at 20:34







  • 2




    @Sergiy I know what you’re trying to convey, but in my experience it’s too simplistic and it ends up confusing users. file, and the shared MIME database, apply a sequence of detection tests, some of which look at the first few bytes of a file. But claiming that the first few bytes of a file give an indication of its type gives readers the wrong impression. There is no guaranteed way of determining a file type (unlike Mac OS Classic or PalmOS where each file had a type and creator code).
    – Stephen Kitt
    Sep 22 at 20:47












up vote
11
down vote










up vote
11
down vote









Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.






share|improve this answer














Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that




The mode is a six-character string whose characters mean the
following:




  1. s: file is small (smaller than 4096 bytes)
    l: file is large


  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above



etc.



In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says




The mode printed under the -l option contains 10 characters which are interpreted as follows:



the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.



The next 9 characters are interpreted
as three sets of three bits each.




So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.



¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 22 at 20:17

























answered Sep 22 at 20:01









Stephen Kitt

148k23326394




148k23326394











  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    Sep 22 at 20:17










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    Sep 22 at 20:20






  • 4




    @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    Sep 22 at 20:31







  • 2




    @Sergiy, no, there is no header. There are heuristics to try to guess a file’s type but there is no guaranteed header, or magic number, etc. All sorts of fun and games can be had by abusing those guesses.
    – Stephen Kitt
    Sep 22 at 20:34







  • 2




    @Sergiy I know what you’re trying to convey, but in my experience it’s too simplistic and it ends up confusing users. file, and the shared MIME database, apply a sequence of detection tests, some of which look at the first few bytes of a file. But claiming that the first few bytes of a file give an indication of its type gives readers the wrong impression. There is no guaranteed way of determining a file type (unlike Mac OS Classic or PalmOS where each file had a type and creator code).
    – Stephen Kitt
    Sep 22 at 20:47
















  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
    – Monica Heddneck
    Sep 22 at 20:17










  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
    – Stephen Kitt
    Sep 22 at 20:20






  • 4




    @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
    – Stephen Kitt
    Sep 22 at 20:31







  • 2




    @Sergiy, no, there is no header. There are heuristics to try to guess a file’s type but there is no guaranteed header, or magic number, etc. All sorts of fun and games can be had by abusing those guesses.
    – Stephen Kitt
    Sep 22 at 20:34







  • 2




    @Sergiy I know what you’re trying to convey, but in my experience it’s too simplistic and it ends up confusing users. file, and the shared MIME database, apply a sequence of detection tests, some of which look at the first few bytes of a file. But claiming that the first few bytes of a file give an indication of its type gives readers the wrong impression. There is no guaranteed way of determining a file type (unlike Mac OS Classic or PalmOS where each file had a type and creator code).
    – Stephen Kitt
    Sep 22 at 20:47















wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
– Monica Heddneck
Sep 22 at 20:17




wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...)
– Monica Heddneck
Sep 22 at 20:17












I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
– Stephen Kitt
Sep 22 at 20:20




I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc.
– Stephen Kitt
Sep 22 at 20:20




4




4




@Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
– Stephen Kitt
Sep 22 at 20:31





@Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?)
– Stephen Kitt
Sep 22 at 20:31





2




2




@Sergiy, no, there is no header. There are heuristics to try to guess a file’s type but there is no guaranteed header, or magic number, etc. All sorts of fun and games can be had by abusing those guesses.
– Stephen Kitt
Sep 22 at 20:34





@Sergiy, no, there is no header. There are heuristics to try to guess a file’s type but there is no guaranteed header, or magic number, etc. All sorts of fun and games can be had by abusing those guesses.
– Stephen Kitt
Sep 22 at 20:34





2




2




@Sergiy I know what you’re trying to convey, but in my experience it’s too simplistic and it ends up confusing users. file, and the shared MIME database, apply a sequence of detection tests, some of which look at the first few bytes of a file. But claiming that the first few bytes of a file give an indication of its type gives readers the wrong impression. There is no guaranteed way of determining a file type (unlike Mac OS Classic or PalmOS where each file had a type and creator code).
– Stephen Kitt
Sep 22 at 20:47




@Sergiy I know what you’re trying to convey, but in my experience it’s too simplistic and it ends up confusing users. file, and the shared MIME database, apply a sequence of detection tests, some of which look at the first few bytes of a file. But claiming that the first few bytes of a file give an indication of its type gives readers the wrong impression. There is no guaranteed way of determining a file type (unlike Mac OS Classic or PalmOS where each file had a type and creator code).
– Stephen Kitt
Sep 22 at 20:47


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?