165k views
1 vote
For this step, we will use the addresses.txt file. As with part 3, your answers to each step will be the egrep command that successfully accomplishes the given step. a. Find all entries whose zip codes start with the digits 41.

User Awan
by
5.0k points

1 Answer

3 votes

Answer:

egrep 41[0-9][0-9][0-9] addresses.txt

Step-by-step explanation:

Unfortunately I was not able to find the addresses.txt file, however I will explain the usage of the egrep command and the answer given.

egrep is a unix/linux command derived from grep, named after its function:

"Globally search for a Regular Expression and Print matching lines"

the difference with "grep" is that "egrep" allows extended regular expressions, for more complex search patterns.

egrep syntax is as follows:

egrep PATTERN [FILE...]

where PATTERN is the expression to search for, it can be as complex as desired, from a single character, to an expression combining range of numbers, wildcards, non-printable characters, and more.

and FILE is one or more files to search and obtain the PATTERNS.

Finally, regarding to this question, the answer given is:

egrep 41[0-9][0-9][0-9] addresses.txt

We assume the zip code is composed of five consecutive numbers, so our proposed pattern states that the first two numbers are 4 and 1, as requested, and then three more characters within the range 0 to 9.

It will return all the lines in addresses.txt containing a five-digit number starting with 41.

User Valera Kolupaev
by
4.3k points