I've got an exercise to do in which I have been given a fictional email record in which the owner of the email got invited to a certain place for vacation.The log is large though, so to speed things up, I have to use grep in a certain way to find the address where the owner of the email address is heading.The basic form of how an address is written as:name firstNamestreetName streetNumberpostalCode(zip) CityNow I know that postal codes usually are 5 digits long, so I can start looking for the line with the postal code. Until now, I did it like this:grep -C2 ^[0-9][0-9][0-9][0-9][0-9] emailsThis command gives me all lines that start with 5 digits in a row and its surrounding two lines (-C2). With this I was really able to find the address, yet there's still a lot of unnecessary lines that show up around it. I have to specify the search to only get the address.So I tried searching for a line that starts with 5 digits and ends with any letter like this:grep -C2 ^[0-9][0-9][0-9][0-9][0-9][A-Z]$ emailsBut it ends up finding nothing. It's probably because it searches for a line that only contains 5 characters and a letter. But I don't know how to tell grep to search for a line that only searches for a line that starts with 5 digits AND ends with a letter (or even better, a word).My next best try would be searching for the name and the first name by searching for a line which contains only two words. But I don't know how to do that and I can't find any discussion in which this is explained.I hope you guys can help me out, please?
How can I find an address in a large file with grep?
grep