-2
 a=4;
 b=7;
 c=5;

 x =[ a-b ] 
 if (x -gt c) then {
  echo "x  is  greater"

  } else {
  echo " something"
  }

I want to compare x and c ignoring the negative prefix of c.

Cyrus
  • 84,225
  • 14
  • 89
  • 153

1 Answers1

1

I'm assuming you meant "negative prefix of x". There are a ton of errors in your code, are you sure you're writing in bash?

#!/bin/bash

typeset a=4 b=7 c=5

x=$(( a - b ))
x=${x//-/}

if [[ x -gt c ]]; then
    echo "x  is  greater"
else
    echo " something"
fi
Jacek Trociński
  • 882
  • 1
  • 8
  • 23
  • `bash` is actually very strongly typed; it simply has only *one* type: the string. In place of multiple types, it has distinct operators that *interpret* strings as different values. For example, `-gt` treats its arguments as integers, while `>` treats its arguments as strings. – chepner Nov 22 '16 at 12:50