Skip to content
Advertisement

Bash script returning command not found, when setting the PATH [closed]

I am very new to Linux and Bash scripting. Also my first question on stackoverflow.

I am trying to create a bash script which I want to use from any directory. So far this is what I did

Created a simple bash file first

#!/usr/bin/bash
echo "This is a bash script"
exit 0

I set the permissions for execute using chmod +x myfilename.sh

And then I edited the .profile file under ~/.profile

Added the line "export PATH="$PATH:$HOME/bash_course/scripts"

After that I ran the command source ~/.profile

Now I tried to run myfilename from the terminal, but it returns Command not found.

Any idea what could have gone wrong?

I checked the path of my bash and it is /usr/bin/bash

If I run ./myfilename.sh from file path, it is working. But I am trying to run from other directories.

FYI : I am doing all of this on a WSL

Advertisement

Answer

Found the issue. My path was actually /bash-course/scripts and not /bash_course/scripts

I corrected the exported path under .profile

Thanks everyone

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement