Article 59WQ7 bash filter output - detect phone numbers

bash filter output - detect phone numbers

by
aristosv
from LinuxQuestions.org on (#59WQ7)
I am trying to create a filter that will read mobile phone numbers in a calendar, filter only the information I need and output it in a file.

So basically I need it to find the numbers that

- start with 94, 95, 96, 97 and 99
- are 8 digits long
- ignore any spaces in the number
- ignore country prefix (+357 or 00357)

Basically something more robust than what I currently have. Because now it picks up anything that contains (not starts with) 94, 95, 96, 97 and 99 and doesn't ignore country code.

Code:gcalcli --config-folder $dir/auth agenda --tsv \
"$(date -d 'now + 61 minutes')" "$(date -d 'now + 119 minutes')" \
| sed 's/\(.\) /\1/g' \
| grep -e 94 -e 95 -e 96 -e 97 -e 99 \
| sed -E 's/^(.*:.{3}).*([[:digit:]]{8}).*/\1\2/' \
| awk '{print $1 " " $2 " " $5}' \
| awk -F'[- ]' '{ print $3"-"$2"-"$1" "$4" "$5 }' \
>> $dir/events/$(date +"%d_%m_%y")/today_$nexthourlatest?d=yIl2AUoC8zA latest?i=HNXTGUh7VAU:oTf4UgGYYcA:F7zBnMy latest?i=HNXTGUh7VAU:oTf4UgGYYcA:V_sGLiP latest?d=qj6IDK7rITs latest?i=HNXTGUh7VAU:oTf4UgGYYcA:gIN9vFwHNXTGUh7VAU
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments