2016年3月2日 星期三

[Linux 文章收集] Linux / UNIX: Determine File Type

Source From Here
Question
How do I determine the file type under UNIX or Linux like operating systems?

How-To
You need to use the file command to determine file type. File command tests each argument in an attempt to classify it. There are three sets of tests, performed in this order: filesystem tests, magic number tests, and language tests. The first test that succeeds causes the file type to be printed on screen.

file Command Examples
First example:
# file /etc/passwd
/etc/passwd: ASCII text

Another example:
# file /home/voffice/letter.doc
... : Microsoft Office Document

Or let's test C source file:
# file wait.c
wait.c: C source, ASCII text

How about binary file:
# file $(which pwd)
/usr/bin/pwd: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=ceaf8a5790e50ef5b28390951a052152c1caa9db, stripped

Even the device files:
# file /dev/sda{1,2,3}
/dev/sda1: block special
/dev/sda2: block special
/dev/sda3: block special


沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...