在bash脚本中的变量之间复制值 [英] Copy values between variables in bash script
本文介绍了在bash脚本中的变量之间复制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将变量中的数值复制到bash脚本中的另一个变量中.如果是C,我会这样做
How can I copy the numeric value in a variable to another variable in bash script. If this were C, I would do
int a=0;
int b;
a=b;
我正在尝试这样做:
if [ $countip -gt $totalip ];
then
$countip -eq $srctip # <-- My problem is here!
echo $srctip
fi
推荐答案
只要说
countip=$srctip
这是任务在bash中的工作方式.这会将countip设置为srctip的值.如果你想分配srctip然后写
This is how assignment works in bash. This will set countip to the value of srctip. If you want to assign srctip then just write
srctip=$countip
根据下面的评论,这看起来像您想要的.
Based on the comments below this looks like the one you want.
这篇关于在bash脚本中的变量之间复制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文