In my former Fedora 24 it runs well in the bash:
Code: Select all
$ ~/Desktop/testscript
7345429 1,0M -rw-rw-r--. 1 tim tim 1021K 21. Mär 21:32 out001.pnm
7345430 1,0M -rw-rw-r--. 1 tim tim 1021K 21. Mär 22:09 out002.pnm
out002.pnm seems to be blank - removing it...
Now in CentOS 7 the script fails with the following errors:
Code: Select all
$ ~/Desktop/testscript
(standard_in) 1: syntax error
1577485 1,0M -rw-rw-r--. 1 tim tim 1021K 21. Mär 21:30 out001.pnm
/home/tim/Desktop/testscript: Zeile 8: [: : Ganzzahliger Ausdruck erwartet.
(standard_in) 1: syntax error
1577486 1,0M -rw-rw-r--. 1 tim tim 1021K 21. Mär 21:30 out002.pnm
/home/tim/Desktop/testscript: Zeile 8: [: : Ganzzahliger Ausdruck erwartet.
My script:
Code: Select all
#!/bin/bash
for i in out*.pnm
do histogram=`convert "${i}" -threshold 50% -format %c histogram:info:-`
white=`echo "${histogram}" | grep "white" | sed -n 's/^ *\(.*\):.*$/\1/p'`
black=`echo "${histogram}" | grep "black" | sed -n 's/^ *\(.*\):.*$/\1/p'`
blank=`echo "scale=4; ${black}/${white} < 0.005" | bc`
echo `ls -lisah $i`
if [ "${blank}" -eq "1" ]; then
echo "${i} seems to be blank - removing it..."
rm "${i}"
fi
done
Fedora 24:
Code: Select all
Version : 4.3.42
Release : 7.fc24
Größe : 6.1 M
Code: Select all
Version : 4.2.46
Ausgabe : 29.el7_4
Größe : 3.5 M