Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy values between variables in bash script

Tags:

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; 

I am trying to do this:

if [ $countip -gt $totalip ];  then     $countip -eq $srctip # <-- My problem is here!     echo $srctip fi 
like image 226
gomesg Avatar asked Feb 26 '13 17:02

gomesg


1 Answers

Just say

countip=$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.

like image 54
Warwick Masson Avatar answered Sep 20 '22 23:09

Warwick Masson