I'm learning how to make shell scripts in UNIX, but I keep coming across this stupid error. Let's say I make a script like this:
#!/bin/sh
echo HELLO
I save the file as test, and make the command executable by me with chmod 700 test. I save the file in my home directory, and (attempt) to run the file like so:
./test
Only for UNIX to reply back:
./test: Command not found.
What is going on? When I type out ls -l, there is an asterisk next to the file name. That wasn't there before I used the chmod command. Can anyone tell me what I'm doing wrong?
Make it executable:
chmod +x ./test
and make sure you save your file in Unix file format. And: check if your partition is executable (mount).
I had the same problem where I copied the file from Windows to Linux and tried to execute it. I did all suggestions above but nothing helped until I did a dos2unix on the file and that fixed it. It may not be the case for you, but just putting it out there
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With