I want to get some number, and assign the result to a custom string。I want to get numbers and I can use it in the next part of this script
the name of this cript is calQue.sh. the content of it is like:
#!/bin/bash
lsfDir=/opt/ibm/lsf/10.1/linux3.10-glibc2.17-x86_64/bin
Queue="ser short medium large"
for i in $Queue
do
queName=`echo $i"idleNum"`
$queName"idleNum"=`$lsfDir/bhosts hg_$i | grep ok | awk '{if($5==0) print $0}' | wc -l`
done
echo $seridleNum
I ran it,
sh calQue.sh
and it is wrong. the result i got is:
calQue.sh: line 14: seridleNumidleNum=1: command not found
calQue.sh: line 14: shortidleNumidleNum=7: command not found
calQue.sh: line 14: mediumidleNumidleNum=37: command not found
calQue.sh: line 14: largeidleNumidleNum=4: command not found
So i tried other ways like:
for i in $Queue
do
queName=`echo $i`
idleNum=`$lsfDir/bhosts hg_$i | grep ok | awk '{if($5==0) print $0}' | wc -l`
#`echo $i`Num=$idleNum //it is wrong
#$queName=$idleNum //it is wrong
done
and
Queue="ser short medium large"
for i in $Queue
do
queName=`echo $i`
"$i"idleNum=`$lsfDir/bhosts hg_$i | grep ok | awk '{if($5==0) print $0}' | wc -l`
echo $"$i"idleNum //it is wrong
done
How do i can get correct result, for example:
string seridleNumidleNum should be equal 1;
I find it is right when the string without variable $i
idleNum=`$lsfDir/bhosts hg_$i | grep ok | awk '{if($5==0) print $0}' | wc -l`
echo $idleNum