[英]Shell substitution variable, err in [output]
looking for some help here. 在这里寻求帮助。 I am seeing the below issue
我看到以下问题
y=1
j$y=`cat /home/devteam/auppu/new_ig_1|head -n $y`
ksh: j1=5555555555555555: not found
i have no issue when i cat on the file,like below 我整理文件时没有问题,如下所示
cat /home/devteam/auppu/new_ig_1|head -n $y
5555555555555555
You might have to do something like 您可能需要做类似的事情
y=1
x=j${y}
x=`cat /home/devteam/auppu/new_ig_1|head -n $y`
echo $x
You would need to create an intermediate variable (x in this case) and then assign to it the results of your cat
command 您需要创建一个中间变量(在这种情况下为x),然后将
cat
命令的结果分配给该变量
The simplest way to do this is using an indexed array, like so: 最简单的方法是使用索引数组,如下所示:
y=1
j[$y]=`cat /home/devteam/auppu/new_ig_1|head -n $y`
echo ${j[$y]}
This way you can store multiple invocations of the cat
command in your loop into the associative array referenced by the j
variable. 这样,您可以将循环中对
cat
命令的多次调用存储到j
变量引用的关联数组中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.