' ': 命令未找到 - .bashrc/.bash_profile [英] ' ': command not found - .bashrc / .bash_profile
问题描述
我有 Windows,使用 Cygwin,试图通过我的 .bashrc
文件永久设置 JAVA_HOME
.
I have windows, using Cygwin, trying to set JAVA_HOME
permanently through my .bashrc
file.
.bashrc:
export PATH="$JAVA_HOME/bin:$PATH"
export JAVA_HOME=$JAVA_HOME:"/cygdrive/c/Program Files (x86)/Java/jdk1.7.0_05"
.bash_profile:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
运行 cygwin:
-bash: $'377376if': command not found
-bash: $'then
': command not found
: No such file or directorysu//.bashrc
-bash: /cygdrive/c/Users/jhsu//.bash_profile: line 3: syntax error near unexpected token `fi'
-bash: /cygdrive/c/Users/jhsu//.bash_profile: line 3: `fi'
我不确定我是否从适用于另一个系统的教程中获取了命令,或者我是否遗漏了一个步骤.或者空格导致我的命令无法正常运行.
I am not sure if I took the commands from a tutorial that was meant for another system or if I am missing a step. Or whitespace is causing my commands not to run properly.
我已经查看了多个类似的问题,但我还没有找到一个与我的问题完全相同的问题.
I've looked at multiple similar questions but I haven't found one where the question has my error exactly.
我的家乡:
$ echo $HOME
/cygdrive/c/Users/jhsu
$ echo ~
/cygdrive/c/Users/jhsu/
所以我认为文件应该放在正确的位置.
So I believe the files should be placed in the correct spot.
推荐答案
当 Cygwin 中的所有其他方法都失败时...
尝试对相关文件运行 dos2unix
命令.
Try running the dos2unix
command on the file in question.
当您看到如下错误消息时可能会有所帮助:
It might help when you see error messages like this:
-bash: '
': 命令未找到
Windows 样式的换行符可能会导致 Cygwin 出现问题.
Windows style newline characters can cause issues in Cygwin.
dos2unix
命令修改换行符,使其与 Unix/Cygwin 兼容.
The dos2unix
command modifies newline characters so they are Unix / Cygwin compatible.
注意:dos2unix 命令会就地修改文件,因此在必要时采取预防措施.
CAUTION: the dos2unix command modifies files in place, so take precaution if necessary.
如果需要保留原文件,请先备份.
If you need to keep the original file, you should back it up first.
Mac 用户注意:dos2unix
命令在 Mac OS X 上不存在.
Note for Mac users: The dos2unix
command does not exist on Mac OS X.
查看这个答案,了解使用不同工具的各种解决方案.
Check out this answer for a variety of solutions using different tools.
还有一个 unix2dos
命令可以执行相反的操作:
There is also a unix2dos
command that does the reverse:
它修改了 Unix 换行符,以便它们与 Windows 工具兼容.
It modifies Unix newline characters so they're compatible with Windows tools.
如果您用记事本打开一个文件并且所有行都运行在一起,请尝试unix2dos filename
.
If you open a file with Notepad and all the lines run together, try unix2dos filename
.
这篇关于' ': 命令未找到 - .bashrc/.bash_profile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!