27 Octobre

This commit is contained in:
Adrian POURCHOT 2022-10-27 10:57:44 +02:00
parent 53b070f18f
commit 10f1f00b7b
7 changed files with 107 additions and 0 deletions

30
SCR1.2/TP08/bin2dot-with-for.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo "Usage: $0 <SRC_FILE> <DEST_FILE>"
exit
fi
if [[ ! -f $1 ]]
then
echo "File $1 does not exist!"
exit
fi
if [[ -f $2 ]]
then
echo -n "File $2 already exists. Overwrite? Yes/No --> "
read answer
if [[ $answer != "Yes" ]]
then
exit
fi
cp /dev/null $2
fi
for addr in $(cat $1)
do
x=$(expr substr $addr 1 8)
y=$(expr substr $addr 9 8)
z=$(expr substr $addr 17 8)
t=$(expr substr $addr 25 8)
echo "$((2#$x)).$((2#$y)).$((2#$z)).$((2#$t))" >> $2
done
exit

View File

@ -0,0 +1,30 @@
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo "Usage: $0 <SRC_FILE> <DEST_FILE>"
exit
fi
if [[ ! -f $1 ]]
then
echo "File $1 does not exist!"
exit
fi
if [[ -f $2 ]]
then
echo -n "File $2 already exists. Overwrite? Yes/No --> "
read answer
if [[ $answer != "Yes" ]]
then
exit
fi
cp /dev/null $2
fi
while read addr
do
x=$(expr substr $addr 1 8)
y=$(expr substr $addr 9 8)
z=$(expr substr $addr 17 8)
t=$(expr substr $addr 25 8)
echo "$((2#$x)).$((2#$y)).$((2#$z)).$((2#$t))" >> $2
done < $1
exit

View File

@ -0,0 +1,3 @@
10110010111000101000011101110010
11100101110001010101100101010010
00110010111001101000010001110010

View File

@ -0,0 +1,3 @@
178.226.135.114
229.197.89.82
50.230.132.114

25
SCR1.2/TP08/mult_mat.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo "Usage: $0 <NUM_ARG1> <NUM_ARG2>"
exit
fi
if [[ $1 -lt 0 || $2 -lt 0 ]]
then
echo "Arguments must be both positive!"
exit
fi
if [[ $2 -lt $1 ]]
then
echo "Argument 1 must be less than Argument 2!"
fi
for ((i=$1;i<=$2;i++))
do
for ((j=$1;j<=$2;j++))
do
echo -n $((i*j))
echo -ne "\t"
done
echo -e "\n"
done
exit

16
SCR1.2/TP08/my_seq.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
if [[ $# -lt 1 ]]
then
echo "Usage: $0 <positive-int>"
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