[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to test a object name is an executable ?
From: |
Seth David Schoen |
Subject: |
Re: How to test a object name is an executable ? |
Date: |
Wed, 30 Aug 2023 17:27:38 -0700 |
Budi writes:
> How do we test an object name / string is an executable, as tried it
> won't work:
>
> $ [[ -x cp ]] &&echo YES
> $
> $ [[ -x ls ]] &&echo YES
It works with a full path:
$ [[ -x /bin/ls ]] && echo YES
YES
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
YES