diff --git a/easy/Shell/file.txt b/easy/Shell/file.txt new file mode 100644 index 0000000..501311d --- /dev/null +++ b/easy/Shell/file.txt @@ -0,0 +1,11 @@ +987-123-4567 +123 456 7890 +(123) 456-7890 +987-123-45674 +(123) 456-78904 +9871-123-4567 +(1231) 456-7890 +987-1232-45674 +(123) 4563-7890 +(123) 456-7890 +0(001) 345-0000 diff --git a/easy/Shell/valid_phone_numbers.sh b/easy/Shell/valid_phone_numbers.sh new file mode 100755 index 0000000..7297187 --- /dev/null +++ b/easy/Shell/valid_phone_numbers.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +while read -r line ; do [[ $line =~ ^[0-9]{3}-[0-9]{3}-[0-9]{4}$ ]] && echo $line; [[ $line =~ ^\([0-9]{3}\)[[:space:]][0-9]{3}-[0-9]{4}$ ]] && echo $line;done < file.txt