среда, 12 марта 2014 г.

Математика в линукс

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Mac-n-Cheese:~ nicolas$ echo "2/3" | bc
0
Mac-n-Cheese:~ nicolas$ echo "scale=2; 2/3" | bc
.66
Mac-n-Cheese:~ nicolas$ echo "(2/3)+(7/8)" | bc
0
Mac-n-Cheese:~ nicolas$ echo "scale=2;(2/3)+(7/8)" | bc
1.53
Mac-n-Cheese:~ nicolas$ echo "scale=4;(2/3)+(7/8)" | bc
1.5416
Mac-n-Cheese:~ nicolas$ echo "scale=6;(2/3)+(7/8)" | bc
1.541666
Mac-n-Cheese:~ nicolas$ echo "(2/3)+(7/8)" | bc -l
1.54166666666666666666

1
2
Mac-n-Cheese:~ nicolas$ bc -l <<< "(2/3)+(7/8)"
1.54166666666666666666

среда, 5 марта 2014 г.

Опредиление размера файла

#!/bin/sh +e
export daten=`date -d "-1 day" +"%d.%m.%Y"`
export monthe=`date +%m`
ls -l /root/Dropbox/logs/00/$monthe/LOG_TEMP_00_$daten.txt | awk '{ print $5 }'
Отправка прикрепленого файла
echo "This is the message body" | mutt -a ~/dan -s "subject of message" -- gordan1987@inbox.ru
File list to array
fileItemString=$(cat  /root/list |tr "\n" " ")
fileItemArray=($fileItemString)
echo ${fileItemArray[*]}
Length=${#fileItemArray[@]}
echo $Length
Определение состояния датчиков
#!/bin/sh +e
export daten=`date -d "-1 day" +"%d.%m.%Y"`
export monthe=`date +%m`
fileItemString=$(cat  /root/list |tr "\n" " ")
fileItemArray=($fileItemString)
Length=${#fileItemArray[@]}
for (( Nomer=1; Nomer<$Length; Nomer++ ))
do
export size=`ls -l /root/Dropbox/logs/0$Nomer/$monthe/LOG_TEMP_"0$Nomer"_$daten.txt | awk '{ print $5 }'`
if [ $size -lt ${fileItemArray[0]} ];
then
      echo "$Nomer - Не работает скрипт"
else
    if [ $size -eq ${fileItemArray[0]} ];
then
echo "$Nomer - Не работает датчик"
else
if [ $size -lt ${fileItemArray["$Nomer"]} ];
then
echo "$Nomer - Нет всех данных"
else
if [ $size -ge ${fileItemArray["$Nomer"]} ];
then
echo "$Nomer - Все работает"
fi
fi
fi
fi
done