diff --git a/DEV1.1/TP b/DEV1.1/TP index c131b8f..73b0bc1 160000 --- a/DEV1.1/TP +++ b/DEV1.1/TP @@ -1 +1 @@ -Subproject commit c131b8f5d04a6a171f96c0e0418b661016defe35 +Subproject commit 73b0bc12f0fe37527635c3a172e4da7a1c9988d4 diff --git a/SCR/SCR1.2/TP08/check-data.sh b/SCR/SCR1.2/TP08/check-data.sh new file mode 100755 index 0000000..69051c1 --- /dev/null +++ b/SCR/SCR1.2/TP08/check-data.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +if [[ $# -lt 3 ]]; then + echo "Usage: $0: " +fi + +if [[ $2 -lt 2 || $2 -gt 36 ]]; then + echo "radix should be between 2 and 36 !" + exit 1 +fi + +if [[ -f $3 ]]; then + read -p "reports file exists you want to overwrite it (Y/n) " choice + if [[ choice == "N" ]]; then + echo "user don't want to overwrite the report file exiting.." + exit 0 + fi + + cp /dev/null $3 +fi + +DIGITS=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ + +LEGAL_DIGITS=$(expr substr $DIGITS 1 $2) + +while read line; do + report="" + l=$(expr length $line) + for ((i = 1; i <= l; i++)); do + digit=$(expr substr $line $i 1) + pos=$(expr index $LEGAL_DIGITS $digit) + if [[ pos -eq 0 ]]; then + report=$report$digit + fi + done + echo "$line : $report" + +done <$1 >>$3 diff --git a/SCR/SCR1.2/TP08/strings_representations.txt b/SCR/SCR1.2/TP08/strings_representations.txt new file mode 100644 index 0000000..dffce9a --- /dev/null +++ b/SCR/SCR1.2/TP08/strings_representations.txt @@ -0,0 +1,8 @@ +101 +1011011 +12010 +11011201040 +24A5204 +15E12A122G84K48 +493B6H +789810924 diff --git a/SCR/SCR1.2/TP08/test.txt b/SCR/SCR1.2/TP08/test.txt new file mode 100644 index 0000000..398050c --- /dev/null +++ b/SCR/SCR1.2/TP08/test.txt @@ -0,0 +1 @@ +101