bash 无法使用 mkdir 创建目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17267095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 05:45:40  来源:igfitidea点击:

Unable to create a directory using mkdir

bashmkdir

提问by user2122377

I installed Openfoam a couple of days ago . I could follow the instructions given herewithout facing any major issues. However, when I run the command $mkdir -p $FOAM_RUNtoday, I am getting this error: mkdir: missing operand. I also tried mkdir -p "$FOAM_RUN"(it is suggested here). Even this failed with the error message mkdir: cannot create directory `': No such file or directory. /.bashrc file is updated as per the instructions given on Openfoam website.

我几天前安装了 Openfoam。我可以按照此处给出的说明进行操作而不会遇到任何重大问题。但是,当我$mkdir -p $FOAM_RUN今天运行命令时,出现以下错误:mkdir: missing operand. 我也试过mkdir -p "$FOAM_RUN"这里建议)。即使这失败并显示错误消息mkdir: cannot create directory `': No such file or directory。/.bashrc 文件根据 Openfoam 网站上的说明进行更新。

回答by unxnut

Seems to me that your variable $FOAM_RUNis not defined. You can confirm that by executing the command: echo $FOAM_RUN

在我看来,您的变量$FOAM_RUN未定义。您可以通过执行以下命令来确认:echo $FOAM_RUN

回答by Classified

Like @unxnut said, your variable is not defined. To define the variable, you just type:

就像@unxnut 说的,你的变量没有定义。要定义变量,您只需键入:

FOAM_RUN=dir_name

then your above command will create a directory called "dir_name", or whatever you assign FOAM_RUN.

那么你上面的命令将创建一个名为“dir_name”的目录,或者你分配的任何 FOAM_RUN 目录。

Hope this helps.

希望这可以帮助。