I have a project, the goal it is to extract phone numbers of a data.txt file, so I did a program. Like that :
grep -E '^[ ]{0,9}\([0-9]{3}\) [0-9]{3}-[0-9]{4}[ ]{0,9}$' $1 | sed 's/^[ \t]*//' > all-result-phonenumber-filter.txt
count=$(wc -l all-result-phonenumber-filter.txt)
echo "The number of line is :$count" >> all-result-phonenumber-filter.txt
My problem is when I want to use this program and to execute on my terminal I had to use pipe for my terminal command. I tried many different commands on my terminal and the last one is :
cat data.txt | ./all-phone-number-filter.sh | cat all-result-phonenumber-filter.txt
But this command doesn't work, and I don't know why. So what is the correct command I had to use with this above format please?
I had to use the following format SDTIN | STDOUT for the pipe.
I give you the data.txt file :
(512) 258-6589
(205) 251-6584
(480) 589-9856
(303) 548-9874
(808) 547-3215
(270) 987-6547
(225) 258-9887
(314) 225-2543
(979) 547-6854
(276) 225-6985
les numeros suivants ne sont pas valables pour ce programme :
+512 325
+512 251 2545654654
+512 6546 6464646
+512546546646564646463313
(314) sgf225-2543
(314) 225-2543fsgaf
(314afd) 225-2543
FSd(314) 225-2543
The result I need to have is :
(512) 258-6589
(205) 251-6584
(480) 589-9856
(303) 548-9874
(808) 547-3215
(270) 987-6547
(225) 258-9887
(314) 225-2543
(979) 547-6854
(276) 225-6985
The number of line is :10 all-result-phonenumber-filter.txt