file comand returns wrong mime type

Hi,

I’m executing:

file -bi file_name

It’s returning application/x-awk.

The file is a text file. It’s the “BEGIN {}” on various lines that appears to be the magic mime type match.

I’m editing the file with Kate and/or Nano. I’ve reviewed the man page for file and didn’t see anything. Is there a way to tell file, no this isn’t awk, but text/plain (i.e., line added to file)? Is there a better way to handle this issue? The main issue at this time is with automation, when a file is used and then an action is taken based on the type.

Thank you.

“file” is probabalistic, it doesn’t guarantee 100% correctness and can be mistaken. You can tell file not to try certain tests.

Is the file extension txt? If not, if it’s a distinctive extension, then setting the extension to open with the editor in file associations may work.

The files in the directory don’t have an extension. The majority of the files are plain text, but that’s not a given. That’s why I was using the file command :slight_smile: I’m learn’n a bit here about mime types, but I always thought it was the first x-number of bytes of the file that was the indicator and not content in the entire file.

Thank you.