diff --git a/SCR/SCR1.2/TP08/bin2dot-with-for.sh b/SCR/SCR1.2/TP08/bin2dot-with-for.sh index 445b239..edb5607 100755 --- a/SCR/SCR1.2/TP08/bin2dot-with-for.sh +++ b/SCR/SCR1.2/TP08/bin2dot-with-for.sh @@ -7,25 +7,28 @@ fi dst_file=$(cat $2) if [[ dst_file -gt 0 ]]; then read -p "$2 exists. Overwrite? Yes/No --> " -r choice + if [[ $choice = "Yes" ]]; then + echo "overwriting $2 !" + echo -n "" >$2 + fi + else echo "file empty" fi -if [[ $choice = "Yes" ]]; then - echo "overwriting $2 !" - echo -n "" >$2 -fi for line in $(cat $1); do - if [[ $(expr length $line) -e 32]]; then + if [[ $(expr length $line) -eq 32]]; then l1=$(expr substr $line 1 8) l2=$(expr substr $line 9 8) l3=$(expr substr $line 18 8) l4=$(expr substr $line 26 8) - echo "$((2#$l1)).$((2#$l2)).$((2#$l3)).$((2#$l4))" >>$2 + echo "$((2#$l1)).$((2#$l2)).$((2#$l3)).$((2#$l4))" >> $2 + else + echo "Invalid format for : $line the string isn't 32bits long" fi