命令存在但在bash脚本中找不到[重复]

时间:2022-07-11 23:56:43

This question already has an answer here:

这个问题在这里已有答案:

I have the following script, script.sh:

我有以下脚本script.sh:

`echo $1 $2`

When I run script.sh hd file I get the error:

当我运行script.sh高清文件时,我收到错误:

script.sh[1]: hd: not found

But when I run hd file in the command line the command runs successfully. How come inside the bash script the command does not exist and outside the script it does exist?

但是当我在命令行中运行hd文件时,命令运行成功。如果命令不存在于bash脚本中,并且在脚本之外它确实存在?

1 个解决方案

#1


-1  

i think u just need to modify

我想你只需要修改

echo '$1 $2'

and than run this might solve

而不是运行这可能会解决

yaah but the main role of that backticks is that it executes commands in backticks before main command

是啊但是反引号的主要作用是它在主命令之前在反引号中执行命令

#1


-1  

i think u just need to modify

我想你只需要修改

echo '$1 $2'

and than run this might solve

而不是运行这可能会解决

yaah but the main role of that backticks is that it executes commands in backticks before main command

是啊但是反引号的主要作用是它在主命令之前在反引号中执行命令