简体   繁体   English

命令行参数bash中没有这样的文件或目录错误

[英]Command line argument No such file or directory error in bash

I have written a bash script and when it is executed as 我已经写了一个bash脚本,当它被执行为

./script a b c

it is working fine. 它工作正常。 then I moved the script to the bin folder and tried to execute it as 然后我将脚本移到bin文件夹并尝试以

script a b c 

now it is showing error 现在它显示错误

a: No such file or directory
b: No such file or directory
c: No such file or directory

Any ideas on how to fix this? 有想法该怎么解决这个吗?

Rename your script. 重命名脚本。 I suppose program script is installed on your system. 我想程序script已安装在您的系统上。

See from your bash: man script 从bash看: man script

You execute your script with file as a parameter. 您将文件作为参数执行脚本。 When you execute by using 当您使用执行

$ ./script a b c 

parameter file and script are same location. 参数文件和脚本位于同一位置。 after moving the file bin folder may be execute script from different location where your parameter file not there. 移动文件bin文件夹后,可能会从不存在参数文件的其他位置执行脚本。

So execute your script with location of file 因此,使用文件位置执行脚本

$ script /path/of/a /path/of/b /path/of/c

then it will be worked fine. 那就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM