'\\ r':找不到命令 - 的.bashrc / .bash_profile中 [英] '\r': command not found - .bashrc / .bash_profile

查看:1813
本文介绍了'\\ r':找不到命令 - 的.bashrc / .bash_profile中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Windows,使用Cgywin,试图通过我的的.bashrc 的文件永久设置JAVA_HOME。

的.bashrc:

 出口PATH =$ JAVA_HOME /斌:$ PATH
出口JAVA_HOME = $ JAVA_HOME:/ cygdrive / C /程序文件(x86)/Java/jdk1.7.0_05

.bash_profile文件:

 如果[-f〜/ .bashrc中]然后
   源的〜/ .bashrc
科幻

的cygwin运行:

  -bash:$'\\ 377 \\ 376if':命令未找到
-bash:$'然后\\ r':命令未找到
:没有这样的文件或directorysu // bashrc中。
-bash:/cygdrive/c/Users/jhsu//.bash_profile:3号线:附近意外的标记'网络语法错误
-bash:/cygdrive/c/Users/jhsu//.bash_profile:3号线:`科幻

我不知道如果我把从已意味着另一个系统,或者如果我缺少的一个步骤的教程中的命令。或空白是导致我的命令无法正常运行。

我看了多个类似的问题,但我还没有找到一个地方问题有我的错误完全吻合。

感谢

编辑#1:

我的主路径

  $回声$ HOME
/ cygdrive / C /用户/ jhsu

所以我相信这些文件应该被放置在正确的位置。

编辑#2:

回声〜

  $呼应〜
/ cygdrive / C /用户/ jhsu /


解决方案

当一切都失败了Cygwin中...

尝试在有问题的文件运行 DOS2UNIX的命令。

这可能有助于当你看到这样的错误信息:

-bash:'\\ r':找不到命令

视窗风格换行符会导致Cygwin的问题。

DOS2UNIX的命令修改换行符,使他们的Unix / Cygwin的兼容。

注意:命令unix2dos修改文件的的,所以在必要时采取precaution

如果您需要保留原文件,你应该先对其进行备份。

注意Mac用户: DOS2UNIX的命令在Mac OS X不存在

查看这个答案适用于各种使用不同的工具解决方案。


有也是做相反的一个 unix2dos 命令:

它修改Unix的换行符所以他们与Windows兼容的工具。

如果你用记事本打开一个文件和所有线一起跑,尽量 unix2dos文件名

I have windows, using Cgywin, 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

running cygwin:

-bash: $'\377\376if': command not found
-bash: $'then\r': 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.

Thanks

EDIT #1:

my home path

$ echo $HOME
/cygdrive/c/Users/jhsu

So I believe the files should be placed in the correct spot.

EDIT #2:

echo ~

$ echo ~
/cygdrive/c/Users/jhsu/

解决方案

When all else fails in Cygwin...

Try running the dos2unix command on the file in question.

It might help when you see error messages like this:

-bash: '\r': command not found

Windows style newline characters can cause issues in Cygwin.

The dos2unix command modifies newline characters so they are Unix / Cygwin compatible.

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.

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.


There is also a unix2dos command that does the reverse:

It modifies Unix newline characters so they're compatible with Windows tools.

If you open a file with Notepad and all the lines run together, try unix2dos filename.

这篇关于'\\ r':找不到命令 - 的.bashrc / .bash_profile中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆