41 lines
591 B
Bash
41 lines
591 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
if [[ $# -lt 2 ]]
|
||
|
then
|
||
|
echo "Usage: $0 <mumarg1> <numarg2>"
|
||
|
exit
|
||
|
fi
|
||
|
|
||
|
if [[ -f $2 ]]
|
||
|
then
|
||
|
read -p "File $2 exists. Overwrite ? Yes/ No --->" answer
|
||
|
exit
|
||
|
fi
|
||
|
if [[ $answer != "Yes" ]]
|
||
|
then
|
||
|
exit
|
||
|
fi
|
||
|
cp /dev/null $2
|
||
|
fi
|
||
|
|
||
|
ARG=$1
|
||
|
ARG2=$2
|
||
|
addr=$1
|
||
|
|
||
|
for addr in (cat "$ARG");
|
||
|
|
||
|
do
|
||
|
|
||
|
binaire1=$(expr substr $addr 1 8)
|
||
|
octet1=$((2#$binaire1))
|
||
|
binaire2=$(expr substr $addr 9 8)
|
||
|
octet2=$((2#$binaire2))
|
||
|
binaire3=$(expr substr $addr 17 8)
|
||
|
octet4=$((2#$binaire3))
|
||
|
binaire4=$(expr substr $addr 25 8)
|
||
|
octet4=$((2#$binaire4))
|
||
|
|
||
|
echo addr_dot="$octet1.$octet2.octet3.octet4" >> $ARG2
|
||
|
|
||
|
done
|
||
|
exit
|