Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Analysis using file Command

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you the relevant knowledge points about the use of file commands to analyze examples. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.

The file command is used to detect the type of a given file. The inspection of files by file command can be divided into three processes: file system, magic number check and language check.

Example 1: default

After file, follow the file directly to get the following information

➜file book.pdfdelete.pdf: PDF document, version 1.3➜ file bookdelete: PDF document, version 1.3

You can see that it doesn't matter whether you add a suffix or not.

Example 2: do not display the name ➜file-b book.pdfPDF document, version 1.3

Plus-b parameter, is the meaning of brief, will only display the file identification results, not the file name, which is actually not very friendly for many files.

Example 3: output understandable information ➜file-I delete.pdfdelete.pdf: application/pdf; charset=binary

Adding the-I parameter is the meaning of the mime type, and I don't know what it means, but I can easily read the meaning of the file type I want to know. That's enough, isn't it? after all, we're here to use file commands.

Example 4: view the file information of the file name in the file ➜cat hello.txtsunset.jpg➜ file-f hello.txtsunset.jpg: JPEG image data, JFIF standard 1.01

This sounds so mouthful, actually very simple, actually not difficult, plus the-f parameter, is the meaning of the file-from type, in the end is how many meanings, that is, you want to view the file type information of the file name in a file, read the file from this file to the information, you can know as follows.

Example 5: good-looking chicken ribs ➜file-F "=" sunset.jpg sunset.jpg = JPEG image data, JFIF standard 1.01

To tell you the truth, I don't understand what this function does. By default, it feels good, but of course this should be customized, as shown below:

Example 6: view the file information of the soft link ➜file a.jpg a.jpg: symbolic link to `sunset.jpg'➜ file-L a.jpg a.jpg: JPEG image data, JFIF standard 1.01

By default, if there is no L parameter, you can only get the information that the file is a soft link. If you add this parameter, you can see the file information of the source file, which is still a great feature.

These are all the contents of the article "file Command use example Analysis". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report