我正在使用Mac,并且我有一个脚本文件print_hello
:
#!/bin/bash
echo hello
如果我直接使用
./print_hello
命令和zsh终端从目录运行它,它将正确打印hello。我想将其添加为全局命令,因此在终端中写入print_hello
应该会显示“hello”。但是我得到的是:zsh: command not found: print_hello
路径是正确的(我在
.zshrc
中对其进行了编辑)。该文件具有适当的权限(我使用了chmod 755 print_hello
):➜ ~ echo $PATH
/Users/mateusz/bin:/usr/local/bin:/Users/mateusz/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/GE/bin:~/scripts
且
print_hello
文件在~/scripts
中我可以直接从脚本目录运行脚本的唯一方法。我应该怎么办?我在
.zshrc
中添加了一些别名,这些别名可以使用,那么为什么可执行脚本不起作用? 最佳答案
这很奇怪,但是帮助我的是取代
~/scripts
和
$HOME/scripts
在.zhrc文件中
关于bash - zsh-找不到书面脚本的命令,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51062944/