Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k
deleted 2 characters in body; edited tags
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

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 firstName
streetName streetNumber
postalCode(zip) City

Now I know that postal codes usually are 5 ciphersdigits 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] emails

This command gives me all lines that start with 5 ciphersdigits 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 ciphersdigits and ends with any letter like this:

grep -C2 ^´[0-9][0-9][0-9][0-9][0-9][A-Z]$´ emails

But it ends up finding nothing... It's probably because it searches for a line that only contains 5 cipherscharacters 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 ciphersdigits 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?

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 firstName
streetName streetNumber
postalCode(zip) City

Now I know that postal codes usually are 5 ciphers 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] emails

This command gives me all lines that start with 5 ciphers 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 ciphers and ends with any letter like this:

grep -C2 ^´[0-9][0-9][0-9][0-9][0-9][A-Z]$´ emails

But it ends up finding nothing... It's probably because it searches for a line that only contains 5 ciphers 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 ciphers 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?

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 firstName
streetName streetNumber
postalCode(zip) City

Now 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] emails

This 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]$´ emails

But 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?

I've got an exercise to do in which iI 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 grepgrep in a certain way to find the address where the owner of the email address is heading. The

The basic form of how an address is written is

name firstName

streetName streetNumberas:

postalCode(zip) City

name firstName
streetName streetNumber
postalCode(zip) City

Now iI know that postal codes usually are 5 ciphers long, so iI can start looking for the line with the postal code. Until now i, I did it like this:

grep -C2 ^[0-9][0-9][0-9][0-9][0-9] emails

grep -C2 ^[0-9][0-9][0-9][0-9][0-9] emails

This command gives me all lines that start with 5 ciphers in a row and its surrounding two lines  (-C2-C2). With this I was really able to find the address, yet theresthere'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

So I tried searching for a line that starts with 5 ciphers and ends with any letter like this: grep -C2 ^´[0-9][0-9][0-9][0-9][0-9][A-Z]$´ emails

grep -C2 ^´[0-9][0-9][0-9][0-9][0-9][A-Z]$´ emails

But it ends up finding nothing... It's probably because it searches for a line that only contains 5 ciphers and a letter. But iI don't know how to tell grepgrep to search for a line that only searches for a line that starts with 5 ciphers AND ends with a letter(or even better, a word). My

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?

I've got an exercise to do in which i have 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 is

name firstName

streetName streetNumber

postalCode(zip) City

Now i know that postal codes usually are 5 ciphers 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] emails

This command gives me all lines that start with 5 ciphers in a row and its surrounding two lines(-C2). With this I was really able to find the address, yet theres 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 ciphers and ends with any letter like this: grep -C2 ^´[0-9][0-9][0-9][0-9][0-9][A-Z]$´ emails

But it ends up finding nothing... It's probably because it searches for a line that only contains 5 ciphers 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 ciphers 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...

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 firstName
streetName streetNumber
postalCode(zip) City

Now I know that postal codes usually are 5 ciphers 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] emails

This command gives me all lines that start with 5 ciphers 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 ciphers and ends with any letter like this:

grep -C2 ^´[0-9][0-9][0-9][0-9][0-9][A-Z]$´ emails

But it ends up finding nothing... It's probably because it searches for a line that only contains 5 ciphers 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 ciphers 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?

Source Link
Loading