Regular paths for bash do not work in termux app. I tried: /usr/bin/bash and /bin/bash Also 'whereis' command gives the following output: $ whereis bash bash: /data/data/com.termux/files/usr/bin/bash But this path also is not correct. So, I have to run every bash script with the word 'bash' before it. And cannot run bash scripts without it.
In September 2017 the maintainer of Termux released a package
termux-exec, which wraps up
execve(2) so that files that has a shebang line like
#!/usr/bin/env will run correctly in Termux. Just run
pkg install termux-exec
and restart Termux (or open a new session). You'll now be able to run
The previous solution was as following:
Termux provides a handy utility
Whose description reads:
Rewrite shebangs in specified files for running under Termux, which is done by rewriting
Just apply it to the scripts you wish to run. It does what its name suggests: fix the shebang line
#!/xxxof your script files. It can also fix other scripts like Perl or Python.
Also note that by default your working directory is not in
$PATH, so you cannot directly type
myscript.sh, but instead
... or explicitly specify an interpreter shell (in which case you don't need the directory prefix):
bash myscript.sh ^~~~
termux-exec. It's a new utility that should resolve your $PATH issue. Termux-exec allows you to execute scripts with shebangs for traditional Unix file structures. See https://wiki.termux.com/wiki/Termux-exec for more information.