Join David D. Levine for an in-depth discussion in this video Reading and writing files with "r" and "w", part of SED Essential Training.
- The SED command "r," reads in another file…immediately following the specified line.…So I'll just create a file called haha…and we'll make it fairly obvious.…I'll say, put it in all caps, say HAHA…HE SAID "DOWN."…So we can say at the line down,…read the file haha that we just created.…So what this does is it looks for any line…containing the word down and at that line…it will read in the contents of the file haha.…
The space between the "r" and the following file name…is optional but note that in some versions…of SED you can use at most one space.…Note that the "r" command is one of those…that cannot be used with a range of addresses.…It can only be used with a single line number,…pattern, or a dollar sign indicating the end of the input.…The related "w" command, writes the specified line…or lines to a file.…This is in addition to the default behavior…of printing each line after any processing…to the standard output.…
For example, we can take lines 1 through 3…and write them to the file top.…So this command writes the first three lines…
AuthorDavid D. Levine
- Understanding input, output, files, and pipes
- Modifying the "s" command
- Using character classes and quantifiers
- Controlling printing
- Reading and writing files
- Appending, inserting, and editing entire lines
- Writing programs in SED
- Using advanced programming commands
Skill Level Intermediate
1. Sed Command-Line Basics
2. Regular Expressions
Using & and \n5m 34s
3. Sed Command-Line Flags
4. More sed Commands
5. Writing Programs in sed
Exiting with "q" and "d"3m 5s
6. Advanced Programming Concepts
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.