Bla*_*man 55 command-line bash
我正在更新我的 .bash_profile,不幸的是我做了一些更新,现在我得到了:
env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
-bash: tar: command not found
-bash: grep: command not found
-bash: cat: command not found
-bash: find: command not found
-bash: dirname: command not found
-bash: /preexec.sh.lib: No such file or directory
-bash: preexec_install: command not found
-bash: sed: command not found
-bash: git: command not found
Run Code Online (Sandbox Code Playgroud)
我的 bash_profile 实际上引入了其他 .sh 文件(来源它们),所以我不确定是哪个修改可能导致了这种情况。
现在,如果我什至尝试查看文件列表,我会得到:
>ls
-bash: ls: command not found
-bash: sed: command not found
-bash: git: command not found
Run Code Online (Sandbox Code Playgroud)
关于如何跟踪错误源以及如何使用终端来处理诸如列出文件等基本内容的任何提示?
Jan*_*ary 74
在我看来,您有时会覆盖默认PATH环境变量。您遇到的错误类型表明PATH不包含/bin上述命令(包括bash)所在的位置。
例如,如果你这样做
PATH=/home/user/bin
Run Code Online (Sandbox Code Playgroud)
代替
PATH="$PATH":/home/user/bin
Run Code Online (Sandbox Code Playgroud)
K. *_*gor 24
开始调试 bash 脚本的一种方法是使用 -x 选项启动子shell:
$ bash --login -x
Run Code Online (Sandbox Code Playgroud)
这将向您显示在启动该 shell 时执行的每个命令及其参数。
指定 --login 选项是因为 .bash_profile 由登录 shell 读取。有关调试 bash 脚本的更多信息,请访问:http : //tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html。
最终,我认为 1 月的建议对您有用,但该链接值得一读以解决未来的问题。
小智 13
我可能已经发现了问题。它对我有用,它可能对你有用......
我的编辑器默认为 Windows (LF/CR) 保存。由于我同时使用这两个系统,这似乎是合乎逻辑的。当我需要弄乱我的 . 时.bash_profile,我在注释掉并尝试了没有任何效果的事情后意识到。我将保存更改为 OS X 格式(仅限 CR),瞧!终端中不再有“找不到命令”!
可能就是这么简单!
小智 6
在我无法重新运行之后。~/.bash_profile 或任何常用命令,如 whoami、grep 等。我想出了一种方法来重新导出所需的路径:
export PATH=/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/cpanel/composer/bin:/usr/local/easy/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin
Run Code Online (Sandbox Code Playgroud)
这应该适用于大多数系统,尽管其中一些路径并不存在于所有 Linux 软件包中。它对我有用。
| 归档时间: |
|
| 查看次数: |
701427 次 |
| 最近记录: |