Ajout de travaux

This commit is contained in:
2024-12-09 11:58:49 +01:00
parent edf66d071b
commit 2e11e7886c
187 changed files with 8670 additions and 0 deletions

105
23SCR/SCR08/SCR8.txt Normal file
View File

@@ -0,0 +1,105 @@
1/
a)
x=7;for ((i=1;i<=x;i++)); do echo $i; done
b)
#!/bin/bash
if [[ $# -lt 1 ]]
then
echo " Usage : $0 "
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 [[ $# -lt 2 ]]
then
echo " Usage : $0 <NUM_ARG1> <NUM_ARG2>"
exit
fi
if [[ $1 -lt 0 ]]
then
echo " Arg1 must be positive ! "
exit
fi
if [[ $2 -lt 0 ]]
then
echo " Arg2 must be positive ! "
exit
fi
if [[ $1 -gt $2 ]]
then
echo " Arg1 must be less than Arg2 !"
exit
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
3/
a)
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo " Usage : $0 <SCR_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
b)
1) read x; echo "$? x=$x" affiche : 0 x=7
2) read x; echo "$? x=$x" affiche : 0 x=
3) read x; echo "$? x=$x" affiche : 1 x=
read permet d'initialiser une valeur dans une variable

30
23SCR/SCR08/bin2dot-with-for.sh Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo " Usage : $0 <SCR_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 <SCR_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 -r 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,4 @@
10110010111000101000011101110010
11100101110001010101100101010010
00110010111001101000010001110010
11110000111111110000000010101010

View File

@@ -0,0 +1,4 @@
178.226.135.114
229.197.89.82
50.230.132.114
240.255.0.170

32
23SCR/SCR08/mult_mat.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
if [[ $# -lt 2 ]]
then
echo " Usage : $0 <NUM_ARG1> <NUM_ARG2>"
exit
fi
if [[ $1 -lt 0 ]]
then
echo " Arg1 must be positive ! "
exit
fi
if [[ $2 -lt 0 ]]
then
echo " Arg2 must be positive ! "
exit
fi
if [[ $1 -gt $2 ]]
then
echo " Arg1 must be less than Arg2 !"
exit
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
23SCR/SCR08/my_seq.sh Executable file
View File

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