I’ve got a script like this:
dyski=$(df -h)
while read wiersz; do
i=0;
for token in $wiersz
do
case $i in
0)
tresc="$tresc\nSystem plików: $token";
;;
1)
tresc="$tresc\nRozmiar całkowity: $token";
;;
2)
tresc="$tresc\nUżyte miejsce : $token";
;;
3)
tresc="$tresc\nDostępne miejsce: $token";
;;
4)
tresc="$tresc\nProcentowe użycie: $token";
;;
esac
i=$((i+1))
done
tresc="$tresc\n"
done < <(echo "$dyski")
When I run it on my Mandriva, it works fine. But when I move it to the SLES11, it gives an error:
./diskcheck.sh: line 42: syntax error near unexpected token
<'done < <(echo “$dyski”)’
./diskcheck.sh: line 42:
What’s wrong with it? Thanks in advance for help.
I suspect you’ve made the mistake of assuming that
/bin/shisbasheverywhere. A number of Linux distributions use simpler shells (oftendash, sometimesksh) as/bin/sh; if you want to usebash-specific extensions such as<(pipeline)syntax, you should explicitly usebashas the shell.