unixowe-systemy-operacyjne/choinka.sh
2023-04-24 16:25:47 +02:00

66 lines
872 B
Bash
Executable File

echo ""
before=6
after=0
leaf=0
# go over all rows of the tree
for ((j=1;j<=25;j++))
do
# drawing what is before the leaf
for ((c=1;c<=before;c++))
do
echo -n " "
done
# draw the leaf
echo -n "*"
# draw what is after the leaf, but before the trunk
for ((c=1;c<=after;c++))
do
echo -n " "
done
# draw trunk
echo -n "##"
# AND everything reversed
for ((c=1;c<=after;c++))
do
echo -n " "
done
echo -n "*"
for ((c=1;c<=before;c++))
do
echo -n " "
done
# going to the next row
echo ""
((before=before-1))
((after=after+1))
if [ $before -eq -1 ]
then
# drawing the end of one branch
echo "*******##*******"
before=6
after=0
((leaf=leaf+1))
if [ $leaf -eq 3 ]
then
# drawing the end of the tree - just the trunk
for ((c=1;c<=3;c++))
do
echo " ## "
done
exit
fi
fi
done
echo ""