#!/bin/bash
sed 's/[^0-9 ]*//g' $1 | tr " " "\n" > outfile.txt
sed '/^\s*$/d' outfile.txt > outfile1.txt
if [ $2 == "-s" ] || [ $2 == "-si" ] || [ $2 == "-is" ]
then
sum=0;
while read num;
do ((sum += num));
done < outfile1.txt;
echo "SUMA= $sum"
fi
if [ $2 == "-i" ] || [ $2 == "-si" ] || [ $2 == "-is" ]
then
ilo=1;
while read num1;
do((ilo = num1 * ilo));
echo $num1
done < outfile1.txt;
echo "ILOCZYN= $ilo"
fi
this is my script and this is 1st argument file
1 2 3 4 5 4 3 2 3 4 5 4 3
2 2 2 2 22 3 34 4 4 5 5 5 d
3 43 54 5 3
this is what im getting from the script when i want to get an multiply of all the numbers and sum of them
s17545@msh:~$ ./skrypt12.sh logfile.txt -si
SUMA= 241
1
.
. all of the numbers in outfile1.txt
.
3
ILOCZYN= -2888071394797551616
any ideas what i am doing wrong?