Results 1 to 4 of 4

Thread: file comand returns wrong mime type

  1. #1

    Default file comand returns wrong mime type

    Hi,

    I'm executing:

    Code:
    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.

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: file comand returns wrong mime type

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

  3. #3
    Join Date
    Aug 2008
    Location
    Brazil
    Posts
    2,937

    Default Re: file comand returns wrong mime type

    Quote Originally Posted by opensuseforumorg42 View Post
    The main issue at this time is with automation, when a file is used and then an action is taken based on the type.
    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.

  4. #4

    Default Re: file comand returns wrong mime type

    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 :-) 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •