From the course: Ubuntu Linux: Essential Commands

Unlock the full course today

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

Change files programmatically

Change files programmatically

From the course: Ubuntu Linux: Essential Commands

Start my 1-month free trial

Change files programmatically

- [Instructor] Sed and AWK are common tools for changing the content of files programmatically. They both work at the command line and they each have a programming language of their own to determine how to treat the content of a file. In this video, I want to show you some basics, and if you're interested in a lot more detail, be sure to check out our courses dedicated to each tool. Here though, we'll take a look at using regular expressions to change the content of some files. Sed or stream editor, is a great choice for replacing content in a file or as part of a piped command. At its most basic, a sed statement is a command followed by some parameters. The s command, just the letter s, means a substitute, and then we would give it something to look for and something to substitute that with when it finds it. Let's take a look at that with our users.txt file. First, let's take a look at the contents of the file with cat users.txt, and then, we can pipe that into sed, and between two…

Contents