बस उपयोग करें file
:
$ file /usr/bin/add-apt-repository
/usr/bin/add-apt-repository: Python script, ASCII text executable
$ file /usr/bin/ab
/usr/bin/ab: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=569314a9c4458e72e4ac66cb043e9a1fdf0b55b7, stripped
जैसा कि समझाया गया है man file
:
NAME
file — determine file type
DESCRIPTION
This manual page documents version 5.14 of the file command.
file tests each argument in an attempt to classify it. There are three
sets of tests, performed in this order: filesystem tests, magic tests,
and language tests. The first test that succeeds causes the file type to
be printed.
The type printed will usually contain one of the words text (the file
contains only printing characters and a few common control characters and
is probably safe to read on an ASCII terminal), executable (the file con‐
tains the result of compiling a program in a form understandable to some
UNIX kernel or another), or data meaning anything else (data is usually
“binary” or non-printable). Exceptions are well-known file formats (core
files, tar archives) that are known to contain binary data. When adding
local definitions to /etc/magic, make sure to preserve these keywords.
Users depend on knowing that all the readable files in a directory have
the word “text” printed. Don't do as Berkeley did and change “shell
commands text” to “shell script”.
आप इसे अपने निष्पादन योग्य के नाम पर सीधे चलाने के लिए एक ट्रिक का उपयोग कर सकते हैं $PATH
:
$ file $(type -p add-apt-repository | awk '{print $NF}')
/usr/local/bin/add-apt-repository: Python script, ASCII text executable
$ file $(type -p ab | awk '{print $NF}')
/usr/bin/ab: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=569314a9c4458e72e4ac66cb043e9a1fdf0b55b7, stripped
सभी प्रकार के निष्पादन योग्य फ़ाइल प्रकारों को खोजने के लिए जो आपकी निर्देशिकाओं में पाए जा सकते हैं $PATH
, आप यह कर सकते हैं:
find $(printf "$PATH" | sed 's/:/ /g') -type f | xargs file
और file
एक विशेष निर्देशिका में सभी फ़ाइलों को चलाने के /usr/bin
लिए ( उदाहरण के लिए), बस करो
file /usr/bin/*
file
प्रत्येक फ़ाइल के लिए यह देखना होगा कि यह किस प्रकार की फ़ाइल है। क्या सभी फ़ाइलों के लिए कोई सरल विधि है?