Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash 在shell脚本中使用$count作为变量的一半名称时,shell脚本代码出现问题_Bash_Shell - Fatal编程技术网

Bash 在shell脚本中使用$count作为变量的一半名称时,shell脚本代码出现问题

Bash 在shell脚本中使用$count作为变量的一半名称时,shell脚本代码出现问题,bash,shell,Bash,Shell,我正在执行下面的shell脚本 count=1 echo $count sa_pp_$count=45 echo (sa_pp_$count) 我收到了以下错误消息: -bash sa_pp_1 := command not found -bash sa_pp_1 := command not found 我已经试过了,通过放置#/bin/bash也在shell的顶部,即使这样,我也面临着同样的问题。谁能给我建议一下解决这个问题的适当方法吗 有关深入讨论,请参阅。通常,将sa_p

我正在执行下面的shell脚本

count=1 
echo $count 
sa_pp_$count=45 
echo (sa_pp_$count)  
我收到了以下错误消息:

-bash sa_pp_1 := command not found 
-bash sa_pp_1 := command not found

我已经试过了,通过放置
#/bin/bash
也在shell的顶部,即使这样,我也面临着同样的问题。谁能给我建议一下解决这个问题的适当方法吗

有关深入讨论,请参阅。通常,将
sa_pp
设为数组,并将
count
设为该数组中使用的索引更合适,而不是每个数据都有一个完全独立的字符串变量。顺便说一句,我们得到了这个问题的另一个实例--,否则,您将遇到不同的语法错误。