help-bash
[Top][All Lists]
Advanced

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

Re: How to test a object name is an executable ?


From: Leonid Isaev
Subject: Re: How to test a object name is an executable ?
Date: Thu, 31 Aug 2023 00:50:04 +0000
User-agent: Mutt/1.13.4 (2020-02-15)

On Wed, Aug 30, 2023 at 05:27:38PM -0700, Seth David Schoen wrote:
> If you don't know where in the system the executable in question is, you
> could run which in order to search the PATH to find out:
> 
> $ [[ -x $(which ls) ]] && echo YES

type is better here (no need to exec an external command):
-----8<-----
if [[ -x "$(type -fP ls)" ]]; then
        :
fi
----->8-----

HTH,
-- 
Leonid Isaev



reply via email to

[Prev in Thread] Current Thread [Next in Thread]