Reputation: 301
I have this code:
if [ -d "$PATH" ]; then
ABSPATH=$( cd "`echo "$1" | sed 's/[^/]*$//'`";pwd)
fi
when I run it, I get this sed: command not found
.Any command I put inside this "if" blog writes this message, XXX:command not found. I have no idea why. I have exactly the same code elsewhere in my script and it is fine there.
Upvotes: 7
Views: 41104
Reputation: 77187
The nature of your program* snippet implies that you have just overwritten PATH
. PATH
is an important environment variable that lets the shell know where to find commands… commands like sed
. If you overwrite it, sed
will not be found.
Use another name; even lowercase path
will work fine.
*I'm fairly confident that you overwrote PATH because PATH should not be a directory – it should be a colon-separated list of directories. If [ -d $PATH ]
is true it either implies you have a very restrictive context for PATH, or, more likely, you have overwritten it.
Upvotes: 15