Hi - How can I find out under sh whitch file is an unix executable file? Need it for an software inventory. Thanks in advance. Regards - Lazybaer
file filename
The file command indentifies file types based mostly on the magic number
thanks jim
Reading the question another way:
Within shell you can test whether a file is executable.
if [ -x "${filename}" ]
then
echo "This file is executable : ${filename}"
fi
Using "find" you can find all the files which are executable. For example.
find . -type f \( -perm -000100 -o -perm -000010 -o -perm -000001 \) -exec ls -ald {} \;
thanks methyl, very useful
if test -x filename
then
echo Executable.
else
echo Not executable.
fi
I am becoming concerned about the number of decidely weird commands on from scripterworld which are filtering onto this site. From the above link about "find" we see:
find . -ipath "./SCRIPTS/scripter*" -print
Which version of unix will accept this command?
There is a naive belief on this site that all unix and Linux commands are common.
Btw, this is not commercial quality script:
if test -x filename
then
echo Executable.
else
echo Not executable.
fi