mardi 29 septembre 2015

if the first value equal to one then echo

In a bash script I read a file aa001 and return the first value. When the first value is equal to 1, return a message like ok, on the terminal

#!/bin/bash  
varReprise=`head -n 1 aa001`
echo $varReprise
un=1
if [`$varReprise` = `$un`]
 then
   echo " OK "
else 
   echo "not Ok"
fi

But I have the following error when I run the script:

./test: ligne 5: 1 : command not found 
./test: ligne 5: [: « ] » command not found 

Aucun commentaire:

Enregistrer un commentaire