Issue
Issue
I want to run a bash file more easily, I've seen some applications where you only need to type word to execute the script.
Instead of typing ~/folder/file.sh
in the terminal,
I only have to type a_word
to run the file.
Is this possible with bash?
And also, this is on RPiOS's terminal, not sure if it differs.
Solution
Save your file to a location named in PATH. /usr/local/bin/a_word
(no .sh
) is a great example of such a location. Make sure it has executable permissions and starts with a shebang (like #!/usr/bin/env bash
).
When you want to install something just for your own account, it's common practice to create a ~/bin
directory and add it to your PATH (as by adding something like PATH=$PATH:$HOME/bin
in ~/.bash_profile
).
Answered By - Charles Duffy Answer Checked By - David Goodson (WPSolving Volunteer)