linux - 无法在脚本 : Permission denied 中使用 mkdir

标签 linux bash

我正在创建几个脚本来启动一些程序,然后将它们重新放入一个 toplevel.sh 脚本中,第一个脚本是 toplevel_config.sh,我在其中导出我需要的所有路径:

    export TARGET_FOLDER="home2/marwa/Desktop/folder/test_all/prot_x"
    export TARGET_FILE="prot_x"

一切正常,除了在一个脚本中,当我必须创建一个目录时,我有这个错误:

mkdir: cannot create directory ‘/top10_prot_x’: Permission denied

负责的脚本是:

results_path=${TRAGET_FOLDER}/sam_results/vmd_results/namd_results/*.out
top10_path=${TRAGET_FOLDER}/top10_${TARGET_FILE}

if [ ! -d "$top10_path" ]; then
   mkdir "$top10_path"
fi 

最佳答案

您正在尝试以不同于预期的其他路径 mkdir。

您的变量路径是:

results_path=${TRAGET_FOLDER}/sam_results/vmd_results/namd_results/*.out
top10_path=${TRAGET_FOLDER}/top10_${TARGET_FILE}

但你定义

export TARGET_FOLDER="home2/marwa/Desktop/folder/test_all/prot_x"
export TARGET_FILE="prot_x"

因此 ${TRAGET_FOLDER} = null 且不存在。

此外,‘/top10_prot_x’已经解释过了。

关于linux - 无法在脚本 : Permission denied 中使用 mkdir,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40021791/

相关文章:

c++ - 如何通过cpp程序将参数传递给bash脚本

python - 使用 glob 参数递归匹配文件名

linux - Bash 脚本无效空格符号

linux - 模棱两可的重定向

linux - Docker 运行错误 : "Thin Pool has free data blocks which is less than minimum required"

linux - *nix 系统上是否有与 COM 等效的功能?如果不是,那么 *nix 的可重用性方法是什么?

bash - 如何在 bash 中获取 printf 格式的特定参数?

android - 在您的 BIOS 安全设置中启用 VT-x,确保您的 Linux 发行版具有工作的 KVM 模块

Linux FTP : Operation now in progress after restart/put

arrays - 如何修改具有给定索引的数组值?