为什么"mkdir -p"会导致Bash权限错误?

1 permissions bash mkdir

如果我创建一个目录mkdir -p,它会导致脚本出现问题

$ mkdir -p test2/test2

$ cd test2/test2

$ echo '#!/bin/sh
> echo hello' > hello.sh

$ ./hello.sh
bash: ./hello.sh: Permission denied
Run Code Online (Sandbox Code Playgroud)

Oli*_*rth 7

这与此无关mkdir.您根本没有给出hello.sh可执行权限.您需要以下内容:

chmod +x hello.sh
Run Code Online (Sandbox Code Playgroud)