Expert academic support · 100% original work · 24/7 help 24/7 support: support@treatisely.com
Uncategorized

Write a command-line program to determine file type under Unix When running your

  • Posted
  • AuthoradminX
  • Length171 words
  • Reading time1 min

Write a command-line program to determine file type under Unix
When running your program with a file name as the input parameter, it should return the type of the file, such as ‘text file’, ‘executable file’, ‘C++ source code’, ‘pdf file’, ‘doc file’, ‘video avi file’ etc…
As we discussed in class, there are four possible ways to determine the type of a file (ref to Chapter 5 from our textbook):
Comparing the file extension to a list of known extensions;
By reading the first byte of the file and comparing it to a list of existing magic code;
Examining the return from a stat() system call;
For text files, read the contents of the file and try to figure it out;
For the purpose of this homework, you don’t have to implement all of the above four. Select two to program will suffice. Any file that can’t be recognized should show ‘unknown type’.
Submit your source code and a test run result (either a ‘script’ file, or a screenshot).

adminX

Subject expert at Treatisely.

Make your next academic task easier to manage

Tell us what you are working on and take the next step with Treatisely.

Submit your assignment free