提问人:Mohit kumar 提问时间:6/3/2023 最后编辑:Andrey BienkowskiMohit kumar 更新时间:6/9/2023 访问量:186
使用此代码将 Homebrew 添加到 Linux 上的路径时,如何修复“意外令牌附近的语法错误”?
How do I fix 'syntax error near unexpected token' when adding Homebrew to my path on Linux using this code?
问:
我正在尝试通过此代码将自制软件添加到我的路径中
Echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv) "') >> /home/mohit/.profile
并收到此错误 -bash :意外令牌附近的语法错误') '
答:
0赞
Peter Whittaker
6/9/2023
#1
你写道:
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv) "') >> /home/mohit/.profile
但这包含一个额外的,就在关闭之后。你可能想要的是)
'
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/mohit/.profile
请注意,这将导致你存在的最后一行.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
哪些可能是您想要的,或者可能包含您并不真正需要的引号。如果需要帮助,
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
将命令更改为echo
echo 'eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)' >> /home/mohit/.profile
另请注意,每次运行该行时,该行都会添加到您的 ;如果这种情况可能会发生多次,您可能需要类似echo
.profile
profile=/home/mohit/.profile
expression='eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)'
if grep -q "${expression}" "${profile}"; then
echo No update required
else
echo "'${expression}'" >> ${profile}
echo profile updated
fi
让它发生一次,而且只发生一次。
评论
)
(