APL/APL1.2/SCR1.2/TP08/ bin2dot-with-read.sh
2021-11-30 15:07:19 +01:00

28 lines
528 B
Bash

#!/bin/bash
if [[ $# -lt 2]]
then ech"Usage: ./bin2dot-with-read.sh <SRC_FILE> <DEST_FILE>"
exit
fi
if [[ $# -f $1]]
then
echo "File $1 does not exist !"
exit
fi
if [[ $# -f $2]]
thenecho -n "$2 exists. Overwrite ? Yes/No --> "
read answer
if [[answer == Yes]]
then cp /dev/null $2
else done
fi
lignes = $(cat $1)
while read i
do
x = $(expr substr $i 1 8)
y = $(expr substr $i 9 8)
z = $(expr substr $i 17 8)
t = $(expr substr $i 25 8)
echo "$((2#$x)).$((2#$y)).$((2#$z)).$((2#$t))"
done <$1 >$2
exit