blob: 8038708208dde912086a0c63fd08f5cf43adc644 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/bin/sh
#
# See ../README.md
#
#
# Run as: bash ch-1.sh < input-file
#
set -f
IFS="" # This way, we keep the spaces as is.
valid="[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]"
while read line
do raw=${line// } # Remove spaces
raw=${raw/#+/00} # Replace leading + with 00
raw=${raw/#([0-9][0-9])/0000} # Replace leading (NN) with 0000
left=${raw/$valid} # Remove 14 digits
if [ "X$left" == "X" ] # If nothing left, the input is valid
then echo $line # Print it
fi
done
|