0
    #!/bin/bash

YESTERDAY=`TZ=GMT+48 date +%Y%m%d`
filename="import$YESTERDAY.log"
today=`date +%Y%m%d`
today="import$today.log"

value1=$(grep -i 'Invalid cells in file' "$filename" | cut -f2 -d':') // gives result 2458



value2=$(grep -i 'Invalid cells in file' "$today" | cut -f2 -d':') // gives result 1236

difference='$value1'-'$value2'
treshold=1000

if [[ $difference -gt $treshold ]]
then

I am tryng to subtract results of those grep's but it gives operator error which shown below

line 14: [[: $value1-$value2: syntax error: operand expected (error token is "$value1-$value2")

CoskunM
  • 1
  • 3

1 Answers1

0

You might try to use the $((...)) notation, as you can see in this example:

Prompt>v1=2458
Prompt>v2=1236
Prompt>echo $((v1-v2))
Prompt>1222

So, for you it means the following:

difference=$((value1-value2))
Dominique
  • 16,450
  • 15
  • 56
  • 112