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.

-- 
Never eat more than you can lift.
                -- Miss Piggy

Eduardo M KALINOWSKI
[email protected]


-- 
To UNSUBSCRIBE, email to [email protected] 
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to