Join David D. Levine for an in-depth discussion in this video Deleting lines with "d", part of SED Essential Training.
- Another said command that is much more interesting…when used with an address or addresses is d,…which deletes the specified line or lines.…I'll use the nl command again to number the lines…and make it clear of what's going on.…For example, if we say…4d, this deletes line 4.…You could also…delete all lines containing up,…or you could delete all lines containing thousand…to lines containing down.…
So, that last command deletes…from the first occurance of thousand,…to the next subsequent occurrence of down inclusive.…The d command is often used with…the exclamation point modifier.…For example,…we'll delete from…only lines that do not contain…the word up.…Or we could…specify lines 2 through 4,…you see ! to invert it.…This deletes everything except lines 2 through 4.…
Which is the same as printing lines 2 through 4.…You can use the p command to check which lines…an address or addresses will affect,…then change the p to d, to perform the deletion.…Keep in mind though, that as with s,…the d command only affects saids output,…
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.