Есть вот такой скрипт:
for file in `find . -iname "*.jpg" -or -iname "*.png" -or -iname "*.jpeg"`;do
ext=${file##*.}
if [ -n "$ext" ]; then
if [ "$ext" = "jpg" ]; then
echo "optimizing ${file} as jpeg file with jpegtran"
jpegtran -copy none -optimize -perfect -outfile temp_abracadabra_filename.jpg $file
mv -f temp_abracadabra_filename.jpg $file;
fi
if [ "$ext" = "jpeg" ]; then
echo "optimizing ${file} as jpeg file with jpegtran"
jpegtran -copy none -optimize -perfect -outfile temp_abracadabra_filename.jpeg $file
mv -f temp_abracadabra_filename.jpeg $file;
fi
if [ "$ext" = "png" ]; then
echo "optimizing ${file} as png file with pngcrush"
pngcrush -rem alla -reduce -brute "$file" temp_abracadabra_filename.png;
mv -f temp_abracadabra_filename.png $file;
fi
fi
done;
При запуске выдает:
./optimzie-image
./optimzie-image: строка 3: ошибка синтаксиса около неожиданной лексемы `then'
./optimzie-image: строка 3: ` if [ -n "$ext" ]; then'
В чем может быть проблема?
then' ./optimzie-image: строка 5:
if [ -n "$ext" ]; then' os ubuntu 14.04