27 Octobre
This commit is contained in:
parent
53b070f18f
commit
10f1f00b7b
30
SCR1.2/TP08/bin2dot-with-for.sh
Executable file
30
SCR1.2/TP08/bin2dot-with-for.sh
Executable 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
|
30
SCR1.2/TP08/bin2dot-with-read.sh
Normal file
30
SCR1.2/TP08/bin2dot-with-read.sh
Normal 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
|
3
SCR1.2/TP08/bin_ipv4_addres.dat
Normal file
3
SCR1.2/TP08/bin_ipv4_addres.dat
Normal file
@ -0,0 +1,3 @@
|
||||
10110010111000101000011101110010
|
||||
11100101110001010101100101010010
|
||||
00110010111001101000010001110010
|
3
SCR1.2/TP08/dot_ipv4_addres.dat
Normal file
3
SCR1.2/TP08/dot_ipv4_addres.dat
Normal 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
25
SCR1.2/TP08/mult_mat.sh
Executable 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
16
SCR1.2/TP08/my_seq.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user