[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: script: test binary program vs shell script



I came to this solution too !

Thanks,
Jerome

Eduardo M KALINOWSKI wrote:
Jerome BENOIT wrote:
Eduardo M KALINOWSKI wrote:
On Qui, 16 Abr 2009, "Jerome BENOIT" wrote:
Hello List,

in side a bash script, I would like to test is a given program
is either a binary file or a script file:
is there way to so ?
file /path/to/program
I know file:
file /path/to/program gives a pretty print answer for human beings,
but I would like something as inhuman as
[ -x /path/to/program ] || exit 1

Is there a way to do so with file ?

file /path/to/program | grep -q text && echo "I'm a script or another
text file"

or something along those lines. Grepping fo "ELF" can also be useful.


--
Jerome BENOIT
jgmbenoit_at_mailsnare_dot_net


Reply to: