There may be several scripts called exactly the same thing on your file system, so locating it based on the name and then blindly executing it is probably a very bad idea.
To locate it, use find
as shown by J. Chomel in another answer to your question, or use locate
:
$ locate script.sh
This will find all files called script.sh
in locations that are readable by all users based on a database search on your system. Note that the database is updated on a regular basis (once daily or once weekly, depending on how it's configured), so files added since the last file system scan will not be found, but it's a lot faster than find
.
You could use select
to generate a menu from which you could select the correct script and execute it:
$ select script in $( locate script.sh ); do echo "$script"; break; done
Change echo
to command
to actually run the script you've selected rather than just printing its name.