bash 未找到 sed 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29334851/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Sed command not found
提问by sykatch
I have this code:
我有这个代码:
if [ -d "$PATH" ]; then
ABSPATH=$( cd "`echo "" | 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.
当我运行它时,我得到了这个sed: command not found
。我在这个“if”博客中放入的任何命令都会写下这条消息,XXX:command not found。我不知道为什么。我的脚本中的其他地方有完全相同的代码,在那里很好。
回答by kojiro
The nature of your program* snippet implies that you have just overwritten PATH
. PATH
is an important environment variablethat lets the shell know where to find commands… commands like sed
. If you overwrite it, sed
will not be found.
您的 program* 片段的性质意味着您刚刚覆盖了PATH
. PATH
是一个重要的环境变量,它让 shell 知道在哪里可以找到命令……像sed
. 如果你覆盖它,sed
将不会被发现。
Use another name; even lowercase path
will work fine.
使用另一个名称;即使是小写path
也能正常工作。
*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.
*我相当有信心你覆盖了 PATH,因为 PATH 不应该是一个目录——?它应该是一个以冒号分隔的目录列表。如果[ -d $PATH ]
为真,则表示您对 PATH 的上下文有非常严格的限制,或者更有可能的是,您已经覆盖了它。