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
From the course: Ubuntu Linux: Essential Commands
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
-
-
-
-
(Locked)
Files on Linux10m 27s
-
(Locked)
Text files8m 52s
-
(Locked)
Work with files and directories10m 16s
-
File links7m 27s
-
(Locked)
Finding files4m 40s
-
(Locked)
Input/output redirection6m 18s
-
(Locked)
Compare text files4m 43s
-
(Locked)
Compare non-text files3m 20s
-
(Locked)
Compress and decompress files9m 12s
-
(Locked)
Explore regular expressions3m 36s
-
(Locked)
Change files programmatically4m 42s
-
(Locked)
-
-