-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanonymizeNumbers.bash
executable file
·53 lines (34 loc) · 1.45 KB
/
anonymizeNumbers.bash
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
#!/usr/bin/env bash
START=$(date +%s.%N)
#exit when command fails (use || true when a command can fail)
set -o errexit
#exit when your script tries to use undeclared variables
set -o nounset
#(a.k.a set -x) to trace what gets executed
set -o xtrace
# in scripts to catch mysqldump fails
set -o pipefail
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Dir of the script
__root="$(cd "$(dirname "${__dir}")" && pwd)" # Dir of the dir of the script
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")" # Full path of the script
__base="$(basename ${__file})" # Name of the script
ts=`date +'%Y%m%d-%H%M%S'`
#Set the config file
configFile="$HOME/.binJlam/templateConfig"
#Check that the config file exists
#if [[ ! -f "$configFile" ]] ; then
# echo "I need a file at $configFile with ..."
# exit 1
#fi
export DISPLAY=:0
echo Begin `date` .....
echo; echo; echo;
### BEGIN SCRIPT ###############################################################
# This won't quite work as it tuncates the last 4 digits, which I try to keep
grep -ho "\(([2-9][0-9]\{2\})\|[2-9][0-9]\{2\}\)[ -]\?[0-9]\{3\}[ -]\?[0-9]\{4\}" $* | sort | uniq | grep -v '^$' | xargs -I {} sed -i "s/{}/555555/g"
### END SCIPT ##################################################################
END=$(date +%s.%N)
DIFF=$(echo "$END - $START" | bc)
echo; echo; echo;
echo Done. `date` - $DIFF seconds