[英]Mkdir error, Permission denied
Hi guys my code is as follows:大家好,我的代码如下:
#!/bin/bash
echo "What directory?"
read $dir
mkdir -p "$dir"/Air/Output
mkdir -p "$dir"/Oxy/Output
echo "done"
im getting the error "permission denied" Is it a problem我收到错误“权限被拒绝”这是一个问题
You should read dir
, not read $dir
.您应该
read dir
,而不是read $dir
。
With read $dir
, your variable will not be set and with an empty dir
variable, you attempt to create a directory from root /Air/Output
which cause the permission denied.使用
read $dir
,您的变量将不会被设置,并且使用空的dir
变量,您尝试从根目录/Air/Output
创建一个目录,这会导致权限被拒绝。
As sjsam suggest, you may also add a prompt to read
with its -p
option :正如 sjsam 建议的那样,您还可以使用
-p
选项添加一个read
提示:
read -p "What directory?" dir
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.