I've searched and searched on here for an answer, and I think the combination of being a noob at bash, not knowing the right way to do this, and not searching for the right keywords has meant I can't quite get over the last hurdle.
I am looking to write a script doing some checks on our Netapp System. And I have some difficulties to fulfill the 2 first variables (VAR1 & VAR2)... I tried with cut and awk command but all my tries were unsuccessfully.
I have a text file (LUNS) and it looks like :
#SAN1; SAN2
abc1:abc1N
abc2:abc2N
a3:a3N
abcde4:abcde4N
all the lines are text and numeric stuff.
for each line of the tom file, I would like to do:
- get the value of the 1st column in VAR1
- get the value of the 2nd column un VAR2
- run and get a new value VAR3 for a command with VAR1 (it will be the size of the LUN so it will be a numeric value)
- run and get a new value VAR4 for a command with VAR2 (same as bellow)
- compare the numeric values of VAR3 & VAR4
What I did :
cat tom |grep -v "#" |while read ligne ; do
VAR1=awk -F ";" '{print $1}'
VAR2=awk -F ";" '{print $1}'
specific command to get the numeric VAR3 & VAR4 values.
#and run the comparaison like :
if [ "$VAR3" -ne "$VAR4" ]
then
echo "PROBLEM"
if [ "$VAR4" -lt "$VAR3" ] ; then echo $VAR4; rm $VAR4; else echo "call support"; fi
else
echo "Everything is OK"
fi
my awk is not working. i am open to any modification in the config file, or in my way to get the VAR1 & VAR2 variables
Can I have your input on, please?