0

I know I'm doing something wrong here:

for i in `cat $resFile | awk -F: '{print $1}' | awk '{print $2}'`; do
    echo $i
    if [ 1 < $i ] ; then
        /usr/bin/mutt -s "SR Sampling Message" [email protected] < $resFile ; else
        echo "everything's fine"
    fi
done

the if statement returns true every time, I need it to follow the negative result. It should be obvious, I'm just missing it.

The $resFile looks like this:

10.254.254.254  2:34
10.254.254.253  2:34
10.254.254.252  2:34
10.254.254.251  2:34
10.254.254.250  3:41 
10.254.254.249  3:41
10.254.254.248  3:41

I always get output no matter what I put as the threshold for time. I know it's all hacky and I'm using awk, I'm just having trouble with the conditional

3
  • again one abused cat ;) (and your for loop will not work), use $(....commands....) Please, specify what you want get from your $resfile
    – clt60
    Jul 25, 2014 at 19:54
  • that's true. I'm not certain I know a better way, can you show me the way and the light? Jul 25, 2014 at 20:53
  • @user3550476 shellcheck automatically points out this and other basic problems. Jul 25, 2014 at 23:15

1 Answer 1

3

less than operator ( < ) wont work with [ ] you should use

if [ $i -lt 1 ]

if you want to use < operator use (()) brackets like if (( $i > 1 )); then

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.