From the course: LPIC-1 Exam 101 (Version 5.0) Cert Prep

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use regular expressions to delete, change, and substitute text

Use regular expressions to delete, change, and substitute text - Linux Tutorial

From the course: LPIC-1 Exam 101 (Version 5.0) Cert Prep

Start my 1-month free trial

Use regular expressions to delete, change, and substitute text

- [Instructor] For this video, we're going delete, change and substitute texts using the sed stream editor and regular expressions. In the chapter nine directory of the Exercise Files, I've included a system pattern file named "PASSWD". We'll use this file with sed. Be sure you're in the chapter nine directory and then type in "LS" to verify. Now let's use sed to print lines of this file that matches a pattern. This will be the same as using grep. Type in "clear", then type in "sed -n '/root/p' passwd". The pattern that we're matching is the word "root", which is between the forward slashes and then printing the result, which is two lines. The narrow it down to one line we can use an anchor. Type in "clear" and then type in "sed -n '/[caret]", which is the anchor to the beginning of the line, "root/p' passwd" and hit enter. This anchors to the beginning of the line and shows one line; the line that starts with "root".…

Contents