Comment écrire un script shell?

Je veux écrire un shell qui s’exécute jusqu’à ce que quelque chose soit écrit dans un fichier (par un autre processus). J’ai écrit ceci:

PID_FILE=log.txt DONE=0 while [$DONE -eq 0] do cat $PID_FILE | while read LINE do if [$LINE -neq ""]; then echo "Do stuff here" $DONE=1 fi done done echo "DONE" echo "">$PID_FILE 

mais je reçois

 test.sh: 3: test.sh: [0: not found DONE 

Cette ligne:

 while [$DONE -eq 0] 

Besoin d’espaces autour des crochets:

 while [ $DONE -eq 0 ] 

Comme celui-ci:

 if [$LINE -neq ""]; then 

Comme ça:

 if [ $LINE -neq "" ]; then 

Cela aide quand vous savez que \[ est une commande . Voir Pourquoi devrait-il y avoir un espace après ‘[‘ et avant ‘]’ dans le script Bash pour une explication.