在bash脚本中复制变量之间的值

问题描述 投票:12回答:1

如何将变量中的数值复制到bash脚本中的另一个变量。如果这是C,我会这样做

int a=0;
int b;
a=b;

我想这样做:

if [ $countip -gt $totalip ]; 
then
    $countip -eq $srctip # <-- My problem is here!
    echo $srctip
fi
bash
1个回答
17
投票

说啊

countip=$srctip

这就是赋值在bash中的工作方式。这将把countip设置为srctip的值。如果你想分配srctip,那就写吧

srctip=$countip

根据下面的评论,这看起来像你想要的。

© www.soinside.com 2019 - 2024. All rights reserved.