Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: File header size in Bytes

  1. #1
    Join Date
    Jul 2009
    Beans
    57

    File header size in Bytes

    Hi,
    I need to know the file header size of various document type files like pdf, MS-word, Libre Office and any document type file format. I got a list of file format at wikipedia https://en.wikipedia.org/wiki/File_format
    but I
    can't see information about the header size. For instance, I know the header size of bmp file=54 byts.Can some body please guide me any link which tells me this information.

    Zulfi.

  2. #2
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,446
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: File header size in Bytes

    not all file types even have headers. many others vary in size. g/l
    What do you call someone who speaks 3 languages? Trilingual.
    What do you call someone who speaks 2 languages? Bilingual.
    What do you call someone who speaks 1 language? American.

  3. #3
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: File header size in Bytes

    Quote Originally Posted by Skaperen View Post
    not all file types even have headers. many others vary in size. g/l
    +1. Exactly this. You can look at the "file" utility source code for how other projects do it.
    Code:
    $ file /etc/hosts
    /etc/hosts: ASCII text
    
    $ file /bin/bash 
    /bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, 
    interpreter /lib64/l, for GNU/Linux 2.6.32, BuildID[sha1]=6f072e70e3e49380ff4d43cdde8178c24cf73daa, 
    stripped
    And sometimes the header isn't only at the beginning of the file. There are multiple headers throughout some files.

  4. #4
    Join Date
    Jul 2009
    Beans
    57

    Re: File header size in Bytes

    Hi,

    Thanks.

    I tried the following :

    $ info utility/function/LibreOfficeWriter
    info: ./utility/function/LibreOfficeWriter: No such file or directory

    Sorry I can't understand how to use the file utility to extract the header of a LibreOfficeWriter file or a pdf file.Please guide me.

    Zulfi.

  5. #5
    Join Date
    Jul 2009
    Beans
    57

    Re: File header size in Bytes

    Hi,
    I found a link related to file but none of the examples show the retrieval of header bytes:

    https://en.wikipedia.org/wiki/File_%28command%29

    Somebody please provide me some example for retrieving header for libreOffice and pdf files.

    Zulfi.

  6. #6
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: File header size in Bytes

    I hate to say this, but if you are having trouble with what I've shown already, then you are much too new to accomplish what you want, especially for binary, compressed, files like LibreOffice and PDF use.

    Start here to get your Linux-Fu strengthened: http://linuxcommand.org/tlcl.php

    Get the source code for the GNU 'file' utility. Read that. It is C code and full of the sort of example code you'd need to understand and write.

    BTW, why would you use 'info'? That tool is for something completely different. I showed **exactly** how to use 'file'.

  7. #7
    Join Date
    Jul 2009
    Beans
    57

    Re: File header size in Bytes

    Hi,

    I used on .odt but got following information:

    $ file 'prob in timing.odt'
    prob in timing.odt: OpenDocument Text

    No information in terms of bytes.

    Zulfi.

  8. #8
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,446
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: File header size in Bytes

    the program/command named file is not designed to provide details about a file that cannot be seriously used. if the file type has a fixed size header, how does that help anything? the concept of having a header can be very complex. many file types can have a series of sections that vary in size an include something you might call a "section header". what follows is often little subsections. and all of this, including all the headers, might be compressed by a specific algorithm.

    a file format like BMP or WAV is simplistic compared to very "rich" formats like ODT, PDF, XLC or even Microsoft Word. the concept of a header just doesn't apply.

    maybe we could explain this better for you if we knew what you are trying to accomplish.
    What do you call someone who speaks 3 languages? Trilingual.
    What do you call someone who speaks 2 languages? Bilingual.
    What do you call someone who speaks 1 language? American.

  9. #9
    Join Date
    Jan 2010
    Location
    Wheeling WV USA
    Beans
    1,446
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: File header size in Bytes

    a text file has no header. a file that has just printable ASCII characters in the first several bytes that file tries to read, is guessed to be a text file. i could fool it by making a file with the first million bytes being text followed by a compressed binary dump of a database of documents. but what would that accomplish? it wouldn't help anything.
    What do you call someone who speaks 3 languages? Trilingual.
    What do you call someone who speaks 2 languages? Bilingual.
    What do you call someone who speaks 1 language? American.

  10. #10
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu Mate 16.04 Xenial Xerus

    Re: File header size in Bytes

    Quote Originally Posted by zak100 View Post
    Hi,

    I used on .odt but got following information:

    $ file 'prob in timing.odt'
    prob in timing.odt: OpenDocument Text

    No information in terms of bytes.

    Zulfi.
    Nothing exists to do what you have requested that I've heard about. I assumed you intended to code something, because that is the only solution. The 'file' utility will have very similar code to what you need to write. That is the entire reason I pointed it out.

    This sounds like a homework assignment for a programming class.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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