-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilterScript_handphone
More file actions
executable file
·80 lines (57 loc) · 1.69 KB
/
filterScript_handphone
File metadata and controls
executable file
·80 lines (57 loc) · 1.69 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# This script reads a file containing valid and invalid phone numbers and output 2 files
# 1. Output valid handphone numbers to valid file
# 2. Output invalid phone numbers to invalid file
## first we set variables for the file
FILE=thecage_handphones.cvs
FILE_VALID_HANDPHONEFILE=filevalidhandphone.csv
FILE_INVALID_HANDPHONEFILE=fileinvalidhandphone.csv
cat $FILE |\
awk '{
FS=" "
};
{
r="[0-9]";
a=$1;
sub(/+65/,"",a);
sub(/(+65)/,"",a);
sub(/^065/,"",a);
sub(/^0065/,"",a);
sub(/^65 /,"",a);
sub(/^65-/,"",a);
sub(/\(65\)/,"",a);
sub(/-/,"",a);
gsub(/ /,"",a);
#gsub(/[ \t]+/,"",a);
b = substr(a, 0,1);
if (match(toupper(a),toupper(r)) && (length(a)==8) && (b ==8 || b == 9)) {
print a
}
}' |sort -k1 > $FILE_VALID_HANDPHONEFILE
echo "The below shows the total nr of valid handphone numbers"
wc --lines $FILE_VALID_HANDPHONEFILE
cat $FILE |\
awk '{
FS=" "
};
{
r="[0-9]";
a=$1;
sub(/+65/,"",a);
sub(/(+65)/,"",a);
sub(/^065/,"",a);
sub(/^0065/,"",a);
sub(/^65 /,"",a);
sub(/^65-/,"",a);
sub(/\(65\)/,"",a);
sub(/-/,"",a);
gsub(/ /,"",a);
#gsub(/[ \t]+/,"",a);
b = substr(a, 0,1);
if (!(match(toupper(a),toupper(r)) && (length(a)==8) && (b ==8 || b == 9))) {
print $1
}
}' |sort -k1 > $FILE_INVALID_HANDPHONEFILE
echo "The below shows the total nr of invalid handphone numbers"
wc --lines $FILE_INVALID_HANDPHONEFILE
echo "RUN END"