Unix/Lunix Programming Exercise 7 In your CWD, make a text file called phone_num
ID: 3904112 • Letter: U
Question
Unix/Lunix Programming
Exercise 7
In your CWD, make a text file called phone_number.txt that contains at least the following lines.
123 456-7891
123-456-78912
(123)-456-7890
123 456 7890
219-123-4567
(405) 456-7890
Exercise 8
Assume that a valid phone number has the format xxx-xxx-xxxx and each line in the text file does not contain leading or trailing white spaces.
Write a grep command that prints all valid phone numbers in phone_number.txt
Exercise 9
Now Assume that a valid phone number has the format (xxx) xxx-xxxx and each line in the text file does not contain leading or trailing white spaces.
Write a grep command that prints all valid phone numbers in phone_number.txt
Exercise 10
Now Assume that a valid phone number can have either the format xxx-xxx-xxxx or the format (xxx) xxx-xxxx.
Write a grep command that prints all valid phone numbers in phone_number.txt
Explanation / Answer
Exercise8- Answer:
xxx-xxx-xxxx :
Exercise9- Answer:
(xxx) xxx-xxxx : (space between (xxx) and xxx-xxxx)
Exercise10- Answer:
xxx-xxx-xxxx or (xxx) xxx-xxxx
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.