1) a) for((i=1;i<=5;i++));do echo $i;done
for((i=1;i<=7;i++));do echo $i;done
b) !/bin/bash

if [[ $# -lt 1 ]]
then
  echo "usage:my_seq.sh <integer>"
  exit
fi
if [[ $1 -lt 0 ]]
then
  echo "Argument must be positive !!"
  exit
fi
for ((i=1;i<=$1;i++))
do echo $i
done
exit

2) #!/bin/bash
if [[ $# -ne 2 ]]
then
  echo "Usage: ./mult_mat.sh <NUM_ARG1> <NUM_ARG2>"
  exit
fi
if [[ $1 -gt $2 ]]
then
  echo "First argument must be less than second argument !!"
  exit
fi
if [[ $1 -lt 0 ]]
then
  echo "Arguments must be positive !!"
  exit
fi
if [[ $2 -lt 0 ]]
then
  echo "Arguments must be positive !!"
  exit
fi
for ((i=$1;i<=$2;i++))
do
  for ((f=$1;f<=$2;f++))
  do
    echo -ne "$((i*f))\t"
  done
  echo -e "\n"
done
exit
Par défaut, une variable non initialisée vaut ""
par exemple :
y = 3
echo "$x est egal a $y" va renvoyer "  est egal a 3"
le # sert à passer en décimal
3)
a) 
#!/bin/bash
if [[ $# -lt 2]]
then ech"Usage: ./bin2dot-with-for.sh <SRC_FILE> <DEST_FILE>"
exit
fi
if [[ $# -f $1]]
then 
echo "File $1 does not exist !"
exit
fi
if [[ $# -f $2]]
thenecho -n "$2 exists. Overwrite ? Yes/No --> "
read answer 
if [[answer == Yes]]
then cp /dev/null $2
else done
fi
lignes = $(cat $1)
for i in $lignes
do 
     x = $(expr  substr $i 1 8)
    y = $(expr  substr $i 9 8)
    z = $(expr  substr $i 17 8)
    t = $(expr  substr $i 25 8)
    echo "$((2#$x)).$((2#$y)).$((2#$z)).$((2#$t))" >> $2
  done
  exit

b)
  b.a) 0 x=7
  b.b) 0 x= 
  b.c) 1 x=
  b.d) 