On Thu, Aug 31, 2023 at 07:17:22AM +0700, Budi wrote:
> How do we test an object name / string is an executable, as tried it
> won't work:
>
> $ [[ -x cp ]] &&echo YES
> $
> $ [[ -x ls ]] &&echo YEShttps://mywiki.wooledge.org/BashFAQ/081
POSIX specifies a shell builtin called command which can be used
for this purpose:
# POSIX
if command -v qwerty >/dev/null; then
echo qwerty exists
else
echo qwerty does not exist
fi
Plus alternatives.