grep a specific word and sum it
- by Kimi
I want to grep an environment variable
env | grep ABC_IJK[1,2]
currenlty defined variables are like this
ABC_IJK1=123
ABC_IJK1_XYZ=sn123:345
ABC_IJK2=999
ABC_IJK2_XYZ=sn321:999
I only want to get only this
ABC_IJK1=123
ABC_IJK2=999
get number of connections sum them(not 123 + 999) and save in N1 (this one has 2 connection)
so N1=2
get number of connections sum them and save in N2 for other machine (if this have four)
so N2=4
If the value is not there or the variable is not present then N1=1 for below:
ABC_IJK1=
ABC_IJK2=123
Then need to compare it with a MAX_CONNECTION variable
Thanks