Hello, Would someone guide me on how to write a shell script the would search for a phone no using at the end text file using sed or awk and store it in a varaible or print it.
The text file is in this form
text or numbers in first line
text or numbers in second line
.
.
.
Firsname Lastname:KEN:+254456789
The first lines may take any form but the last line will always be
of the form "Firstname Lastname:KEN:+254456789"
I would like to seach for the Phone and store it in a variable and print it.
The phone no will alway be preceeded by ":+"
sample file: test
---------------------------
text or numbers in first line
text or numbers in second line
.
.
.
Firsname Lastname:KEN:+254456789
------------------------------------
The code worked. I one day old in regards to working with awk and sed. Would explain what tail -1 test | cut -d"+" -f2 means. Also how do I append the + back when assigning the results of tail -1 test | cut -d"+" -f2 to variable $phonenum.