Searching text with regular expressions
Lesson 7 of 8 in objective 103. GNU and Unix commands, part of LPIC-1 Exam 101-500.
- Objective
- 103. GNU and Unix commands
- Share of the exam
- 43.33% (the whole objective)
- Questions in this lesson
- 5
- Signed for by a person
- 0
Partly checked. None of the 5 questions here has been read against the cited source by a person. 5 questions have been checked against their cited clause by an automated pass — which is not the same thing, and is not a signature.
Only questions a person has signed for are used in mock exams here. That is the whole difference between the two kinds of checking above.
Questions in this lesson
- You must match one or more consecutive digits using grep with BASIC regular expressions (no -E). Which pattern is correct? machine-checked
- A colleague needs to search a file for the literal string `1.2.3.4` and is worried the dots will match any character. Which command treats the pattern as a fixed string with no regular expression meaning at all? machine-checked
- hosts.txt mixes host names with raw IP addresses. Which command uses a sed address to print ONLY the lines that begin with a digit, each line exactly once? machine-checked
- In `grep '\(ab\)\1' file`, what is the role of `\1`? machine-checked
- Using GNU grep, which THREE characters have their special meaning only when preceded by a backslash in a BASIC regular expression, but are special as typed in an EXTENDED one? machine-checked
Drill this lesson
A lesson is one sitting: the trainer draws a short run from these questions alone and spaces the ones you get wrong.
Practise Searching text with regular expressions
The rest of objective 103
- Working on the command line
- Filtering text streams
- Basic file management
- Streams, pipes and redirection
- Creating, monitoring and killing processes
- Process execution priorities
- Searching text with regular expressions — you are here
- Editing files from the terminal