Write a regular expression that will find all lines in a file named myfile that
ID: 3910776 • Letter: W
Question
Write a regular expression that will find all lines in a file named myfile that end in 'bye.'
(So that hellobye. and bye.bye. would be displayed, but not bye.bye or hellobyee)
grep 'bye.' myfile
Which of the following is considered an extended regular expression?
The find command
all answers are correct
Write a regular expression
to match lines with the following criteria:
+ begins with the single digit 8 or 9
+ contains a lower case letter somewhere in the middle (line may be any length)
+ and ends with the dash character: -
^[8-9].*[a-z].*-$
Write a grep command
to search for the string Heinrich Boll in the contents of a file called
Awards
under the directory
/Books
grep 'Heinrich Boll' /Awards/Books
sed 's/[BW]ill/William/g' somefile
changes the first occurance of 'Bill' or 'Will' to 'William' in somefile
Which command will find all files under /me/mine/ whose name is horses
grep 'bye.$' myfileExplanation / Answer
1. Regular expression that will find all lines in a file named myfile that end in 'bye.'
grep 'bye.$' myfile
2. Which of the following is considered an extended regular expression?
x{8}
3. The find command
can search based on the file size
can recursively search all subdirectories under a starting directory
4. Write a regular expression
to match lines with the following criteria:
+ begins with the single digit 8 or 9
+ contains a lower case letter somewhere in the middle (line may be any length)
+ and ends with the dash character:
^[8-9].*[a-z].*-$
5. Write a grep command
to search for the string Heinrich Boll in the contents of a file called
Awards
under the directory
/Books
grep 'Heinrich Boll' /Books/Awards
6. sed 's/[BW]ill/William/g' somefile
changes all occurances of 'Bill' or 'Will' to 'William' in somefile
7. Which command will find all files under /me/mine/ whose name is horses
find -L /me/mine -name horses
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.