Please help me to find problem
t1=$(sort -k 2,2 f.txt|head -1|cut -d" " -f3)
while read x
do
t2=$(echo $x|cut -d" " -f2)
if [ $t2 -ge $t1 ] ; then
p=$(echo $x|cut -d" " -f1)
echo -n $p " "
fi
done <f.txt
f.txt
F1 13
G 13
H 0
I am geeting following error
-sbash: [: 13: unary operator expected
-sbash: [: 13: unary operator expected
without H 0 row it work correct
‘unary operator expected’ is the error when you use a binary operator with only a single operand.
This means that either t2 or t1 is empty. To cause an empty variable to not disappear, use default notation
${VARIABLE:-DEFAULT}to give them a default value: