unary operator expected cfajohnson - Shell Programming and Scripting - Unix Linux Forums

  Go Back    



unary operator expected

Shell Programming and Scripting




Kindly Note - This is a Single User Post by Forum Member cfajohnson Regarding:
unary operator expected.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old 03-06-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
 
Join Date: Mar 2007
Last Activity: 25 July 2014, 8:14 PM EDT
Location: Toronto, Canada
Posts: 2,877
Thanks: 0
Thanked 110 Times in 102 Posts
Quote:
Originally Posted by Satyak View Post
i am trying to compare a value with value 50. but i am getting
"[: -lt: unary operator expected"

I am using

if [ $j -lt 50 ]
then
echo "------------"

fi

Make sure that $j expands to a value. Best is to set it explicitly, but you can also give it a default value (0 in this example):


Code:
if [ ${j:-0} -lt 50 ]