I am writing my own unix scripts so I want to add a new directory for Bash. I add sth in .bash_profile like this.
PATH="~/Documents:${PATH}"
export PATH
and in my ~/Documents, there is a file named test of which the content is
#!/usr/bin/env python3.5
print("hahahhah")
I also used
chmod 755 test
to make it executable.
But I cannot call it in terminal directly. ./test works as usual.
What went wrong?
After I change to
PATH="$HOME/Documents:${PATH}"
export PATH
nothing happens.
FDSM_lhn@9-53:~/Documents$ test
FDSM_lhn@9-53:~/Documents$ ./test
hahahhah
Solution: The fundamental reason is that I have a command of the same name as default one, So it won't work any way! Changing name will be sufficient!
~/Documentsappear, or the expanded version? Unless it's the expanded version, it won't help, and I think the double quotes prevent the~being expanded. Addecho "$PATH"after theexport PATHand see what it says.