diff --git a/SCR1.2/TP06/tp7-reponses.txt b/SCR1.2/TP06/tp7-reponses.txt deleted file mode 100644 index e69de29..0000000 diff --git a/SCR1.2/TP08/bin2dot-with-for.sh b/SCR1.2/TP08/bin2dot-with-for.sh new file mode 100755 index 0000000..527899e --- /dev/null +++ b/SCR1.2/TP08/bin2dot-with-for.sh @@ -0,0 +1,30 @@ +#!/bin/bash +if [[ $# -lt 2 ]] +then + echo "Usage: $0 " + 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 \ No newline at end of file diff --git a/SCR1.2/TP08/bin2dot-with-read.sh b/SCR1.2/TP08/bin2dot-with-read.sh new file mode 100644 index 0000000..001a091 --- /dev/null +++ b/SCR1.2/TP08/bin2dot-with-read.sh @@ -0,0 +1,30 @@ +#!/bin/bash +if [[ $# -lt 2 ]] +then + echo "Usage: $0 " + 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 \ No newline at end of file diff --git a/SCR1.2/TP08/bin_ipv4_addres.dat b/SCR1.2/TP08/bin_ipv4_addres.dat new file mode 100644 index 0000000..c765b63 --- /dev/null +++ b/SCR1.2/TP08/bin_ipv4_addres.dat @@ -0,0 +1,3 @@ +10110010111000101000011101110010 +11100101110001010101100101010010 +00110010111001101000010001110010 \ No newline at end of file diff --git a/SCR1.2/TP08/dot_ipv4_addres.dat b/SCR1.2/TP08/dot_ipv4_addres.dat new file mode 100644 index 0000000..b1d26ab --- /dev/null +++ b/SCR1.2/TP08/dot_ipv4_addres.dat @@ -0,0 +1,3 @@ +178.226.135.114 +229.197.89.82 +50.230.132.114 diff --git a/SCR1.2/TP08/mult_mat.sh b/SCR1.2/TP08/mult_mat.sh new file mode 100755 index 0000000..7b7486c --- /dev/null +++ b/SCR1.2/TP08/mult_mat.sh @@ -0,0 +1,25 @@ +#!/bin/bash +if [[ $# -lt 2 ]] +then + echo "Usage: $0 " + 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 \ No newline at end of file diff --git a/SCR1.2/TP08/my_seq.sh b/SCR1.2/TP08/my_seq.sh new file mode 100755 index 0000000..933d397 --- /dev/null +++ b/SCR1.2/TP08/my_seq.sh @@ -0,0 +1,16 @@ +#!/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 \ No newline at end of file