#!/bin/bash
#Testare paritate
number=0
echo -n "Enter a number>"
read number
echo "Number is $number"
if [ $((number % 2)) -eq 0 ];then
echo "Numarul este par"
else
echo "Numarul este impar"
fi
#!/bin/bash
#Factorialul unui numar
#Apelare: fact 56
fact ()
{
local num=$1;
if ["$num" = 1]; then
echo 1
return;
fi;
echo $[$num * $(fact $[$num-1])]
}
#!/bin/bash
#Afisare continut arhive
#Apelare: tarview arhiva.tar
tarview() {
echo -n "Displaying contents of $1 "
if [ ${1##*.} = tar ]
then
echo "(uncompressed tar)"
tar tvf $1
elif [ ${1##*.} = gz ]
then
echo "(gzip-compressed tar)"
tar tzvf $1
elif [ ${1##*.} = bz2 ]
then
echo "(bzip2-compressed tar)"
cat $1 | bzip2 -d | tar tvf -
fi
}
#!/bin/bash
#Testare numere prime
number=0
echo -n "Enter a number>"
read number
echo "Number is $number"
for i in 'seq 2 $((number/2))';
do
if [ $((number % 2)) -eq 0 ];then
echo "Numarul nu este prim"
else
echo "Numarul este prim"
fi
done
#!/bin/bash
#Fereastra de dialog
dialog --title "Fereastra mea" --clear --yesno "Contiunuam?" 15 61
case $? in
0)
echo "S-a ales DA";;
1)
echo "S-a ales NU";;
255)
echo "S-a apasat ESC";;
esac