diff --git a/SCR/SCR1.2/TP08/bin2dot-with-for.sh b/SCR/SCR1.2/TP08/bin2dot-with-for.sh index 2375c5e..445b239 100755 --- a/SCR/SCR1.2/TP08/bin2dot-with-for.sh +++ b/SCR/SCR1.2/TP08/bin2dot-with-for.sh @@ -4,9 +4,11 @@ if [[ $# -lt 2 ]]; then echo "usage: $0 " exit 1 fi - -if [[ $(cat $2) -gt 0 ]]; then +dst_file=$(cat $2) +if [[ dst_file -gt 0 ]]; then read -p "$2 exists. Overwrite? Yes/No --> " -r choice +else + echo "file empty" fi if [[ $choice = "Yes" ]]; then @@ -15,12 +17,16 @@ if [[ $choice = "Yes" ]]; then fi for line in $(cat $1); do + if [[ $(expr length $line) -e 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) + 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 + fi + + done diff --git a/SCR/SCR1.2/TP08/ipv4.txt b/SCR/SCR1.2/TP08/ipv4.txt index e3c0141..e69de29 100644 --- a/SCR/SCR1.2/TP08/ipv4.txt +++ b/SCR/SCR1.2/TP08/ipv4.txt @@ -1,12 +0,0 @@ -178.226.14.114 -229.197.178.82 -50.230.8.114 -178.226.14.114 -229.197.178.82 -50.230.8.114 -178.226.14.114 -229.197.178.82 -50.230.8.114 -178.226.14.114 -229.197.178.82 -50.230.8.114