Reputation: 1
I am trying to compare the umask
of an user. I am getting an error while doing the comparison. The code I am using is
val=`su - user -c "umask" | tail -2 | sed -n "/[0-9]/p"`
if [ $val -eq 744 ]
then
echo "477 found."
fi
When I execute this I am geting an error like:
sh: ^[H: A test command parameter is not valid.
I've tried with =
in the compare command, but it is still not working.
Please give any suggestions.
Regards.
val
has been initialised as 0
.
I am running this as root, so no login is there.
I've also tried giving quotes.
Upvotes: 0
Views: 290
Reputation: 11890
Your code executes well on my machine, the only solution I can suggest is to use a slightly different syntax, sometimes different bash version complain about one syntax and accept another one:
val=`su - user -c "umask" | tail -2 | sed -n "/[0-9]/p"`
if [[ $val -eq 477 ]] ; then
echo "477 found."
fi
Have a look here for the difference between [ cond ]
and [[ cond ]]
.
Upvotes: 1