I have a bash script and in it a if statement that I can't get to work:
1 #!/bin/bash
2
3 echo "Please provide expenses for time period specified: "
4 read expenses
5
6 rev_pa=$(psql -U postgres -d crewdb -t -c "SELECT SUM(price) FROM work WHERE date_linkid BETWEEN 100 AND 500;")
7
8 blah=$(echo "$rev_pa-$expenses" | bc)
9
10 if [ "$blah" -lt 0 ]
11
12 then
13 echo "Total expenses of $expenses exceeds total revenue of $rev_pa for the specified time period."
14
15 fi
I used expenses = 10000 and rev_pa = 12208.20 was the database output. The error message I get is:
./bash.txt: line 10: [: 12208.20: integer expression expected
Does anyone know how I can get this if statement to work in bash? Thanks for your help.