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.
The sed command stands for stream editor in UNIX-based systems. It performs text editing operations on text coming from the standard input or a file. It can perform operations such as deletion, searching, find and replace, or insertion in a file even without opening it.
The SED command in Linux stands for Stream EDitor and is helpful for a myriad of frequently needed operations in text files and streams. Sed helps in operations like selecting the text, substituting text, modifying an original file, adding lines to text, or deleting lines from the text.
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.
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