-1

I am getting a syntax error when I try to test the following and it appears to be due to the 0 which is there. What am I missing here?

This is the code:

echo =========================================
echo sum of 4 arguments:"$requestedsum"
if [ -n "$requestedsum" ]
then 
(( $(echo "$requestedsum > $vg_free_space" |bc)));
echo "Requested space is not available in VG";
else
echo "Requested space is available";
fi


=========================================
sum of 4 arguments:0
10
./sizecheck.sh: line 26: ((: 0
1: syntax error in expression (error token is "1")
Requested space is not available in VG
Mike Pierce
  • 1,390
  • 1
  • 12
  • 35
user63858
  • 27
  • 5
  • can you share the entire part of the script that's relevant? – mmenschig Jan 25 '19 at 17:23
  • `(( ... ))` is a conditional, what do you want that line to do? – Benjamin W. Jan 25 '19 at 17:29
  • @BenjaminW, I am trying to compare requestedsum with the existing space numbers. – user63858 Jan 25 '19 at 18:16
  • @mmenschig, I have pasted the bash -x output via external link. I couldn't post it here as site was asking me to put words to finish my edit. Let me know if anything else is needed. – user63858 Jan 25 '19 at 18:17
  • And what's the result of the comparison? Do you want to use it in a conditional? Your code uses the conditional as a command. Can you describe what should happen for each possible outcome? – Benjamin W. Jan 25 '19 at 18:26

1 Answers1

0

I see: requestedsum='0 10'

Seems not to be a simple value. Try to assign a simple value to requestedsum.